Understanding Css+div Positioning

Source: Internet
Author: User

one, div tag and span tag
Div and span can be used as a container, collectively controlling the style within the container
The difference is that Div makes block-level elements, and there are line breaks before and after
span is an inline element and does not wrap around it.

second, box model
1, Concept
Any page element can be viewed as a box
A box model consists of content, padding, border, margin four parts

Third, the positioning of elements

1,float
The value can be left, right, or default None,left and yes on either side of the parent element.
You can set Clear:left, right, and both to clear the effect of float on it

2,position
Static: Default value, keep in position
Absolute: Absolute position, top, bottom, right and left can specify absolute or percentage, and the elements that are added to the page after the CSS default overwrite the original
Relative: Position relative to parent block, top, bottom, right, left
Fixed: Essentially the same as absolute, but the block does not move up and down with the browser scroll bar, IE does not support the fixed property

3,z-index
Z-index refers to the vertical and page direction of the z-axis, the Z-index value of the block on the small value of the block, will form a cover effect DTH (height) value refers to the content of the width (height) +padding The value of the IV can have span, And there's no div in span.

one, div tag and span tag
Div and span can be used as a container, collectively controlling the style within the container
The difference is that Div makes block-level elements, and there are line breaks before and after
span is an inline element and does not wrap around it.
There can be a span within a div, and no div within a span

second, box model
1, Concept
Any page element can be viewed as a box
A box model consists of content, padding, border, margin four parts
The value of width (height) refers to the value of the content's width (height) +padding

2,border
Color
Width:thin, medium, thick, value
Style:none, hidden, dotted, dashed, solid, double, groove, Ridge, inset, outset
Border-top, Border-bottom, Border-left, Border-right
IE does not support Border-style

Background-color in IE middle finger content+padding,ff middle finger content+padding+border

3,padding
Padding-top, Padding-bottom, Padding-left, Padding-right

4,margin
Margin-top, Margin-bottom, Margin-left, Margin-right
For a row, the margin of two blocks = Margin-right + margin-left
For a line, the margin of two blocks = the larger of Margin-bottom and Margin-top
For a parent, the margin of the child block = The margin of the child block + the padding of the parent block
When margin is set to a negative number, the block moves in the opposite direction, even covering the other block

third, the positioning of elements
1,float
The value can be left, right, or default None,left and yes on either side of the parent element.
You can set Clear:left, right, and both to clear the effect of float on it

2,position
Static: Default value, keep in position
Absolute: Absolute position, top, bottom, right and left can specify absolute or percentage, and the elements that are added to the page after the CSS default overwrite the original
Relative: Position relative to parent block, top, bottom, right, left
Fixed: Essentially the same as absolute, but the block does not move up and down with the browser scroll bar, IE does not support the fixed property

3,z-index
Z-index refers to the vertical and page orientation of the z-axis, the large z-index value of the block on the small value of the blocks above, will form a cover effect

iv. signature of pictures

Java code
  1. <div id= "Block1" > "Building.jpg" border= "0" ></div>
  2. <div id="Block2">xxx ' s photo</div>
  3. #block1 {
  4. padding:10px;
  5. border:1px solid #0000;
  6. float  : Left;
  7. }
  8. #block2 {
  9. Color:white;
  10. padding:10px;
  11. Position:absolute;
  12. Left 255px;
  13. top:205px;
  14. }
<div id= "Block1" ></div><div id= "Block2" >xxx ' s photo</ Div> #block1 {  padding:10px;  border:1px solid #0000;  Float:left;} #block2 {  color:white;  padding:10px;  Position:absolute;  Left 255px;  top:205px;}



Five, the text shadow

Java code
  1. <div id= "Block1" >css positioning Shadows </div>
  2. <div id="Block2">css positioning Shadows </div>
  3. #block1 {
  4. position:relative;
  5. Z-index: 1;
  6. }
  7. #block2 {
  8. Color: #AAAAAA;
  9. position:relative;
  10. Top:-1. 06em;
  11. Left: 0. 1em;
  12. Z-index: 0;
  13. }

Understanding Css+div Positioning

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.