CSS Study Notes 3. css Study Notes

Source: Internet
Author: User

CSS Study Notes 3. css Study Notes
CSS box model:


In the early days, webpage design was mainly about tables, and later it was mainly about div + css.

Box Model:

1. border:

Border-top, border-bottom, border-left, and border-right

2. padding:

Padding-top, padding-bottom, padding-left, and padDing-right

3. margin:

Margin-top, margin-bottom, margin-left, and margin-right


CSS layout


Syntax: Float: None| Left| RightValid value:
None : Default Value. Objects are not float
Left : Right of the text flow object
Right : Left side of the text flow object

Syntax: Clear: None| Left| Right| BothValid value:
None : Default Value. Allow floating objects on both sides
Left : Float objects on the left are not allowed
Right : Floating objects on the right are not allowed
Both : Floating objects are not allowed.


<Style type = "text/css">/* body {due to different browsers, you can change the value of the outer border of the body during development. margin: 0px ;} */div {border: #000000; padding-top: 10px; padding-bottom: 50px; padding-left: 100px; padding-right: 150px;/* padding: 10px 50px 100px 150px;/* Top right bottom left */} # div_1 {background-color: # FF0000;/* margin-left: 200px; */float: left; /**/} # div_2 {background-color: # FF9900; float: left;/* clear: left; */} # div_3 {background-color: # 3300FF; /* clear: right; */} </style> 


CSS positioning:

Syntax: Position: Static| Absolute| Fixed| RelativeValid value:
Static : Default Value. No special positioning. Objects follow HTML positioning rules.
Absolute : Drag an object out of the Document Stream and use the left, right, top, bottom, and other attributes to absolutely locate the parent object with the most specific positioning settings relative to the object. If such a parent object does not existBodyObject. Its stack is defined by the z-index attribute.
Fixed : Not Supported. Object positioning follows absolute (Absolute. But comply with some rules
Relative : Objects cannot be stacked, but will be offset in normal document streams based on left, right, top, bottom, and other attributes.


<Style type = "text/css"> div {border: #000000 solid 1px; height: 100px; width: 200px ;}# div_0 {background-color: #66FF99; height: 400px; width: 400px; position: absolute;/* position: static; */top: 100px; left: 100px ;}# div_1 {background-color: # FF0000; /* position: absolute; * // * assume that the parent object div_0 does not define the position. For example, if it is static, its position attribute is relative to the body, that is, to div_0 */position: relative; left: 80px;/* a small program can be used to change the value, so that the box can float on the page */top: 50px; /* this value is relative to the body */} # div_2 {background-color: # FF9900; width: 200px;} # div_3 {background-color: # 3300FF ;} </style> 

In summary, if a position is defined for a foreign region, the position attribute value defined for the inner region is for the foreign region. If not, the inner region is for the body.


CSS text Mixing


<Style type = "text/css"> # imgtext {border: # 3333FF dashed 1px; width: 280px ;}# img {float: right ;#text {color: # F6C; font-family: "文 ";} </style> 


In summary, if a position is defined for a foreign region, the position attribute value defined for the inner region is for the foreign region. If not, the inner region is for the body.

CSS Image Signature
<Style type = "text/css"> # imgtest {border: # FF0000 dotted 1px; width: 350px;/* margin: 50px; */position: absolute; /* the image is not moved, so you need to locate */top: 50px;} # text {font-family: "文 "; font-size: 20px; position: absolute; top: 30px; left: 10px ;} </style> 

The image text in csdn can be saved together. If the image is saved, the text cannot be saved.

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.