CSS position - position property (positioning)
The CSS position property is a syntax used to set the position of an element. You can define where an element (such as a picture, DIV block, h1, h2... etc.) should be displayed on a web page. For example, set a picture in In the upper left corner of the web page, CSS position must usually be used with attributes such as left and top to let the browser know how far the web page elements are to the left and how far to the top. In addition, it can also be used with z-index to create the effect of stacking pictures together. Most mainstream browsers support the position property effect of CSS .
CSS position position property syntax
- absolute: Absolute position. When the page is pulled down, the element will also change position. The position of the element is determined by top, left, right, and bottom.
- fixed: The position of the element is fixed and positioned relative to the browser. The position of the element is determined by top, left, right, and bottom.
- relative: Relative position, relative to the position of other elements, the position of the element is determined by top, left, right, and bottom.
- static: This is the default value. If the position is set to static, top, left, right, and bottom will be ignored.
- inherit: inherit the value of the position positioning attribute from the parent layer.
CSS position position property application example 1: modify the position of a paragraph
position:absolute;
top:80px;
left:80px
}
CSS position position property application example 2: Position relationship between two DIV blocks
<!--
#DIV_BIG{
width:300px;
height:200px;
background-color:#FFB326;
position:relative;
}
#DIV_SMALL{
width:120px;
height:100px;
background- color:#78FF78;
position:absolute;
top:20px;
left:40px;
}
-->
</style>
<div id="DIV_BIG">
<div id="DIV_SMALL"></div>
</div>
Making good use of the relative and absolute properties of CSS position is very important in the position configuration of web page elements.
With the function of the CSS position property, web designers can easily place webpage elements where they want to be placed, such as the position of the website LOGO, the position of the picture in the webpage, the video playback block, the position of the form... . And so on, the application is quite extensive.
Post a Comment
0 Comments