CSS brochure: layout attributes

Source: Internet
Author: User
CSS attributes:
3. Layout attributes:
In the previous HTML, the positions of elements can only be arranged in sequence. In CSS, you can locate elements more accurately. Netscape once proposed Layer tag, which is good for precise layout, but not recognized by W3C. W3C proposed a function similar to Layer tag in CSS.
Position attribute:
The position attribute is used to determine the position type of an element. For details, refer to the attribute:
Attribute name: 'position'
Attribute value: absolute | relative | static
Initial value: static
Target objects: all elements
Inherit?: no
Percentage remarks: Forbidden
The attribute values are:
Absolute: the absolute position on the screen.
Relative: relative position on the screen.
Static: inherent position.
Direction attributes:
The direction attribute determines the arrangement direction of the BOX. For details, refer to the attributes:
Property Name: 'direction'
Attribute value: ltr | rtl
Initial value: ltr
Target objects: all elements
Inherit?: yes
Percentage remarks: Forbidden
Float and clear attributes:
You can select a float location for an image in HTML. Currently, you can select a float location for a BOX object through CSS. Change the float attribute of the BOX. The BOX will float the left or right of other elements:
Property Name: 'float'
Attribute value: left | right | none
Initial value: none
Target objects: all elements
Inherit?: no
Percentage remarks: Forbidden
For example:
<STYLE type = "text/css">
IMG {float: left}
BODY, P, IMG {margin: 2em}
</STYLE>
<BODY>
<P>

Some sample text that has no other...
</BODY>
On the contrary, the clear attribute is used to prevent elements from floating on the left or right of the BOX:
Property Name: 'clear'
Attribute value: left | right | both | none
Initial value: none
Target objects: all elements
Inherit?: no
Percentage remarks: Forbidden
Absolute position attribute:
The absolute position attribute has four attributes: top, right, bottom, and left. The attribute value is the length unit or percentage:
Attribute name: 'top', 'right', 'bottom ', and 'left'
Attribute value: <length >|< percentage> | auto
Initial value: none
Target objects: all elements
Inherit?: no
Percentage remarks: Forbidden
With the preceding attributes, you can precisely define the position of an element, for example:
<P style = "position: relative; margin-right: 10px; left: 10px;">
1st 2 3 pages
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.