1. Relative positioning
-Aim for yourself
-Small offset
-Do not leave the team (stream)//position will not be released
Position:relative
Left: Value
Right: Value
<!doctype html>
<meta charset= "Utf-8"/>
<title> Photo Wall </title>
<style>
/* Brush the Wall First */
body{
Background-color: #088;
}
/* Re-set the photo */
ul{
width:780px;
margin:20px Auto;
border:1px solid red;
/* Remove the symbol */
List-style-type:none;
}
li{
width:218px;
padding:10px;
margin:10px;
border:1px solid #ccc;
Float:left; Left float guaranteed Picture Positive order
Background-color: #fff;
}
p{
Text-align:center;
}
/* Use relative positioning to achieve the effect of photo jitter */
li:hover{
position:relative;
left:2px;//2 pixels to the right with the Li left boundary as the benchmark
The top:-2px;//is based on the Li upper boundary and is offset upward by 2 pixels
}
</style>
<body>
<ul>
<li>
<p> softly I'm Gone </p>
</li>
<li>
<p> as I softly come </p>
</li>
<li>
<p> I waved quietly </p>
</li>
<li>
<p> goodbye to the clouds of the West </p>
</li>
<li>
<p> Green Willow at the riverside </p>
</li>
<li>
<p> is the bride in the Sunset </p>
</li>
</ul>
</body>
2. Absolute positioning
-Targeting the Fathers
With position fathers, if there is no position, then the body as the goal, if more than the parents with position
To target the nearest fathers.
-Large offset
-Out of Stream (troop)//position will be released
Position:absolute
Left: Value
Top: Value
Absolute location instance:
<!doctype html>
<meta charset= "Utf-8"/>
<title> News Photos </title>
<style>
div{
border:1px solid red;
width:390px;
height:258px;
/* Set the positioning property for the child element to make absolute positioning of the DIV for the target */
position:relative;
}
/* Absolute Positioning */
p{
Position:absolute;
top:0;
left:0;
margin:0;
width:100%;
Text-align:center;
line-height:30px;
Background-color: #ccc;
}
</style>
<body>
<div>
<p> Little Plum finally won the Golden Man </p>
</div>
</body>
3. Fixed positioning
-Target the window
-Huge offsets
-Out of Stream (troop)
-Forever hanging on the window, anyway scrolling, all over there
Position:fixed
Left: Value
Right: Value
<!doctype html>
<meta charset= "Utf-8"/>
<title>demo</title>
<style>
div{
width:50px;
line-height:30px;
Text-align:center;
Background-color: #ccc;
/* Fixed positioning */
position:fixed;
bottom:10px;//to the bottom edge of the window, offset up to 10 pixels
right:5px;//to the right of the window, offset to the left by 5 pixels
}
</style>
<body>
<div>
<a href= "#" >top</a>//the anchor point at the top of the browser form does not have a name
</div>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p> it's as big as 5S </p>
<p></p>
</body>
Relative positioning, absolute positioning and fixed positioning of webbasic