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.