Summarize the four positioning properties common in CSS (left right top bottom)

Source: Internet
Author: User
DIV CSS left right top bottom Locate the four CSS property styles used to locate the object box, you must define the Position property value to absolute or relative.

The distance from the left of the current element to the left side of the parent element (which is the original default position).

The distance value to the right of the current element to the right of the parent element.

Top the distance from the top of the current object that is above the original position.

Bottom the distance from the bottom of the current object to the original location.

A. Left property in CSS

1. Detailed description of left property in CSS

Definition and usage

The Left property specifies the right edge of the element. This property defines the offset between the left margin boundary of the anchored element and the left boundary of its containing block.

Note: If the value of the "position" property is "static", setting the "left" property has no effect.

2. Detailed example of CSS three-column layout (figure)

Implemented by float left and relative width

Absolute positioning, by absolute positioning it out of the document flow, can be adapted to define the three column width

Use float, float left and float right

3. The difference between offsetleft and Style.left in Div

The ClientX event property returns the horizontal coordinates of the mouse pointer to the browser page (or client area) when the event is triggered.
The customer area refers to the current window.
If the parent P's position is defined as relative, the position of the child p is defined as absolute, then the style.left value of the child p is relative to the value of the parent p, which is the same as Offsetleft

4. Div's Float:left and span tags

The difference is that p? is a block-level (Block-level) element that wraps around the elements automatically. span is simply an inline element that does not wrap around it. There is no structural meaning, it is purely an applied style, and the elements can be used when other inline elements are not appropriate. It is important to note that the tag can be included in the tag, become his child element, and vice versa.

Two. The right property in CSS

1. CSS Border-right-style Property sets the right border style of the element

CSS Border-right-style Property sets the right border style of an element

The style of the border refers to the line property of the border, which refers to the solid line effect, the short-term effect, or the other line effect of the border.

The Border-right-style property sets the style of the right border of an element.

2. Margin-right not work? _html/css_web-itnose

The browser renders the element from left to right by default, without exceeding the width of the parent container if the width of the child container can be accommodated setting margin-right is useless

3. Summary of CSS Margin-left and margin-right usage methods

Generally in CSS styles, use the margin property to set the margin. If you need only one side of the margin, you can use the unilateral margin property to set the value for the margin on the element's unilateral edge. Use the Margin-left property to set the left margin of the element. Use the Margin-right property to set the right margin of the element. They have a default value of 0. You can set the specific unit value in the actual use, or you can set the form as a percentage. This article summarizes how margin-left and Margin-right are used.

Three. Bottom properties in CSS

1. Introduction of five ways of using CSS to achieve footer bottom

The footer base (Sticky footer) is the footer portion of the page that is always at the bottom of the browser window.

When the page content is long enough to exceed the viewable height of the browser, the footer will be pushed to the bottom of the page as the content is placed, but if the page content is not long enough, the bottom footer will remain in the browser window.

2. CSS Border-bottom (refers to the style, width and color of the set edge)

The Border-bottom property is used to specify the style, width, and color of the bottom line, with half-width spaces spaced between values, with no precedence.

The value of the style of the Border-bottom property, which refers to the style of the edge. Value of the width of the edge, depending on the width of the edge

3. IE6 under Margin-bottom set negative number is hidden problem _html/css_web-itnose

However, in IE6, the bottom border of the current tab does not cover the bottom border of the parent element, and the web says that the parent element is going to go haslaytout, try not to, and finally set the margin-bottom:-1px in the tab element; position:relative; This will solve the problem.

Note here that the height of the tab element must be 1px greater than the height of the parent element.

Four. Top properties in CSS

1. CSS Margin-top frequently encountered in the use of the summary of problems

In CSS styles, the Margin-top property sets the top margin of the element. It can allow negative values to be used. The default definition of the fixed top margin value is 0. All major browsers support the Margin-top property. Through this article we come to the specific point of use in the front-end page of the Margin-top property frequently encountered some problems, such as the setting after the impact of the parent element? Using the Margin-top property does not work how to resolve it? Wait a minute

2. Explore the use of border-top properties in CSS

This section about CSS Border-top property usage is easier to learn, and the Border-top shorthand property sets all the properties of the top border to a single declaration.

This article describes the use of CSS border-top properties, border-top shorthand property to set all the properties of the top box to a declaration, I believe this article will let you have something to gain

3. CSS3 Border-top-left-radius Properties

The main point is to add a rounded border to the four corners of the DIV element:

Note: The two length or percent value of the Border-top-left-radius attribute defines the shape of the ellipse's One-fourth edge corner of the outer border. The first value is the horizontal radius and the second one is the vertical radius. Omitting the second value, it is copied from the first one. If any length is zero, the corners are square and not rounded. The percentage of the horizontal radius refers to the width of the bounding box, and the percentage of the vertical radius is the height of the bounding box.

Questions and answers about positioning attributes (left right top bottom):

1. CSS-The right mouse button to display the pop-up window absolute, left and top for the mouse click on the Clientx, Y, in IE bottom for auto

2. CSS-about offsetleft and offsettop

3. CSS-in the iphone browser, when input type is date, the Text-align:right property does not take effect

4. HTML-Ask Margin-top questions

"Related recommendations":

1. Learn CSS video tutorials in the blink of an fingertips

2. A CSS for interpretation; Left:900em and Left:auto_html/css_web-itnos.

3. Summary of common methods of using CSS to locate background images

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.