-
-
Save 13hoop/467fed1467066ad6af8370313e5cd7a3 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/ladana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
* { | |
border: 1px solid gray; | |
} | |
.wrapper { | |
max-width: 300px; | |
margin: 0 auto; | |
text-align: center; | |
height: 1000px; | |
} | |
.main1 { | |
background: #aaa; | |
position: relative; | |
left: 40px; | |
} | |
.main2 { | |
background: #3ae; | |
} | |
.main3 { | |
background: #bfe; | |
position: fixed; | |
max-width: 100px; | |
bottom: 0px; | |
left: 0px; | |
} | |
.fa { | |
color: yellow; | |
position: relative; | |
left: -2px; | |
background: red; | |
} | |
.son { | |
background: #000; | |
color: white; | |
position: absolute; | |
top: 17px; | |
right: 80px; | |
left: 80px; | |
} | |
.clear { | |
clear: both; | |
content: ''; | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrapper"> | |
this is relative demo | |
<p class="main1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nostrum praesentium nam tempora beatae quis nobis laboriosam alias aliquid, tenetur exercitationem. Odio, aperiam, illo! Eveniet natus dignissimos architecto velit eligendi id!</p> | |
this is static | |
<p class="main2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nostrum praesentium nam tempora beatae quis nobis laboriosam alias aliquid, tenetur exercitationem. Odio, aperiam, illo! Eveniet natus dignissimos architecto velit eligendi id!</p> | |
<p class="main3">This is fixed! This is fixed! This is fixed! This is fixed! This is fixed!</p> | |
<hr> | |
<div class="fa"> | |
----- father relavite here, 但是div不再包裹p了 ------- | |
<p class="son">this is absolute position. this is absolute position. this is absolute position. this is absolute position. this is absolute position</p> | |
</div> | |
</div> | |
<script id="jsbin-source-css" type="text/css">* { | |
border: 1px solid gray; | |
} | |
.wrapper { | |
max-width: 300px; | |
margin: 0 auto; | |
text-align: center; | |
height: 1000px; | |
} | |
.main1 { | |
background: #aaa; | |
position: relative; | |
left: 40px; | |
} | |
.main2 { | |
background: #3ae; | |
} | |
.main3 { | |
background: #bfe; | |
position: fixed; | |
max-width: 100px; | |
bottom: 0px; | |
left: 0px; | |
} | |
.fa { | |
color: yellow; | |
position: relative; | |
left: -2px; | |
background: red; | |
} | |
.son { | |
background: #000; | |
color: white; | |
position: absolute; | |
top: 17px; | |
right: 80px; | |
left: 80px; | |
} | |
.clear { | |
clear: both; | |
content: ''; | |
display: block; | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
border: 1px solid gray; | |
} | |
.wrapper { | |
max-width: 300px; | |
margin: 0 auto; | |
text-align: center; | |
height: 1000px; | |
} | |
.main1 { | |
background: #aaa; | |
position: relative; | |
left: 40px; | |
} | |
.main2 { | |
background: #3ae; | |
} | |
.main3 { | |
background: #bfe; | |
position: fixed; | |
max-width: 100px; | |
bottom: 0px; | |
left: 0px; | |
} | |
.fa { | |
color: yellow; | |
position: relative; | |
left: -2px; | |
background: red; | |
} | |
.son { | |
background: #000; | |
color: white; | |
position: absolute; | |
top: 17px; | |
right: 80px; | |
left: 80px; | |
} | |
.clear { | |
clear: both; | |
content: ''; | |
display: block; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
somehow about
position
why last div BFC not working?