[Html]
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Link href = "css/reset.css" rel = "stylesheet" type = "text/css"/>
<Link href = "css/layout.css" rel = "stylesheet" type = "text/css"/>
<Title> No title page </title>
</Head>
<Body>
<Div id = "wraper">
<H3>
Popular movies <Div id = "film">
<Div class = "top">
</Div>
<Div class = "filmname">
The story of the dog's eight male </div>
</Div>
</Div>
</Body>
</Html>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Link href = "css/reset.css" rel = "stylesheet" type = "text/css"/>
<Link href = "css/layout.css" rel = "stylesheet" type = "text/css"/>
<Title> No title page </title>
</Head>
<Body>
<Div id = "wraper">
<H3>
Popular movies <Div id = "film">
<Div class = "top">
</Div>
<Div class = "filmname">
The story of the dog's eight male </div>
</Div>
</Div>
</Body>
</Html>
Iii. CSS
[Css]
# Wraper
{
Text-align: center;
}
# Film
{
Position: relative;
Width: pixel PX;
Height: 254px;
}
# Film. top
{
Position: absolute;
Top: 0;
Left: 0;
Width: 53px;
Height: 48px;
Background: url (../images/p_dot.png) 0px-1027px;
}
# Film. filmname
{
Position: absolute;
Bottom: 0px;
Left: 0px;
Width: 100%;
Text-align: center;
Color: Red;
Font-size: 24px;
Font-family: 文;
Font-weight: bolder;
}
# Wraper
{
Text-align: center;
}
# Film
{
Position: relative;
Width: pixel PX;
Height: 254px;
}
# Film. top
{
Position: absolute;
Top: 0;
Left: 0;
Width: 53px;
Height: 48px;
Background: url (../images/p_dot.png) 0px-1027px;
}
# Film. filmname
{
Position: absolute;
Bottom: 0px;
Left: 0px;
Width: 100%;
Text-align: center;
Color: Red;
Font-size: 24px;
Font-family: 文;
Font-weight: bolder;
}
Basic knowledge]
The attribute position in CSS is usually located in the following ways:
Value description
Absolute generates absolute positioning elements, which are located relative to the first parent element other than static positioning.
The positions of elements are specified by the "left", "top", "right", and "bottom" attributes.
Fixed generates absolute positioning elements, which are located relative to the browser window.
The positions of elements are specified by the "left", "top", "right", and "bottom" attributes.
Relative generates relative positioning elements and locates them relative to their normal locations.
Therefore, "left: 20" adds 20 pixels to the LEFT position of the element.
Static default value. The element is not located and appears in the normal stream (ignore the top, bottom, left, right, or z-index declarations ).
Inherit specifies that the value of the position attribute should be inherited from the parent element.
[Description]
1. The instance image is from the website of Xunlei:
Background: url (../images/p_dot.png) 0px-1027px;
2. relative to <div id = "film">, you must set position: relative ;, although the left, right, top, and bottom values are not actually given.
3. If this non-default location is not available, the location is non-static. The reference object for the absolute location will be the body, that is, the form.
4. The difference between absolute and relative mainly lies in the difference in the positioning of the reference object. The reference object of relative is its normal position.