Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | ||
<title>居中样式</title> | ||
<style> | ||
html,body,div,ul,li{ | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.inner{ | ||
list-style: none; | ||
} | ||
.inner>li{ | ||
width: 300px; | ||
height: 100px; | ||
background: rgb(0,66,16); | ||
float: left; | ||
margin-top: 20px; | ||
margin-left: 10px; | ||
margin-right: 10px; | ||
margin-bottom: 10px; | ||
} | ||
.wrapper{ | ||
width: 940px; | ||
margin-top: 30px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
background: rgb(204,204,204); | ||
} | ||
.inner{ | ||
margin-left: -10px; | ||
margin-right: -10px; /*这里是利用负margin扩大面积,不是移位。因为如果一个元素没有width,只有左右负margin,它就会变宽。*/ | ||
overflow: hidden; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<ul class="inner"> | ||
<li>1</li> | ||
<li>2</li> | ||
<li>3</li> | ||
<li>4</li> | ||
<li>5</li> | ||
<li>6</li> | ||
</ul> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | ||
<title>使用圣杯布局实现三栏布局</title> | ||
<style> | ||
html,body,div{ | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.header,.footer{ | ||
height: 40px; | ||
background: rgb(204,204,204); | ||
} | ||
.wrapper{ | ||
padding: 0 200px; | ||
} | ||
.wrapper:after{ | ||
content: ""; | ||
display: block; | ||
clear: both; | ||
} | ||
.wrapper>.main{ | ||
width: 100%; | ||
height: 100px; | ||
background: green; | ||
float: left; | ||
} | ||
.wrapper>.aside{ | ||
width: 200px; | ||
height: 150px; | ||
background: red; | ||
float: left; | ||
margin-left: -100%; /*默认盒模型,这里的100%是父容器内容的100%。所以设置内外边距要加到包裹容器的上面*/ | ||
position: relative; | ||
left: -200px; | ||
} | ||
.wrapper>.extra{ | ||
width: 200px; | ||
height: 150px; | ||
background: yellow; | ||
float: left; | ||
margin-left: -200px; | ||
position: relative; | ||
left: 200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header">header</div> | ||
<div class="wrapper"> | ||
<div class="main">main</div> | ||
<div class="aside">aside</div> | ||
<div class="extra">extra</div> | ||
</div> | ||
<div class="footer">footer</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | ||
<title>利用圣杯布局实现两栏布局</title> | ||
<style> | ||
html,body,div{ | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.header,.footer{ | ||
height: 40px; | ||
background: rgb(204,204,204); | ||
} | ||
.wrapper{ | ||
padding: 0 0 0 200px; | ||
} | ||
.wrapper:after{ | ||
content: ""; | ||
display: block; | ||
clear: both; | ||
} | ||
.wrapper>.main{ | ||
width: 100%; | ||
height: 100px; | ||
background: green; | ||
float: left; | ||
} | ||
.wrapper>.aside{ | ||
width: 200px; | ||
height: 150px; | ||
background: red; | ||
float: left; | ||
margin-left: -100%; | ||
position: relative; | ||
left: -200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header">header</div> | ||
<div class="wrapper"> | ||
<div class="main">main</div> | ||
<div class="aside">aside</div> | ||
</div> | ||
<div class="footer">footer</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | ||
<title>利用双飞翼布局实现三栏布局</title> | ||
<style> | ||
html,body,div{ | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.header,.footer{ | ||
height: 40px; | ||
background: rgb(204,204,204); | ||
} | ||
.wrapper:after{ | ||
content: ""; | ||
display: block; | ||
clear: both; | ||
} | ||
.wrapper>.middle{ | ||
width: 100%; | ||
float: left; | ||
} | ||
.wrapper>.middle>.main{ | ||
height: 100px; | ||
margin: 0 200px; | ||
background: green; | ||
} | ||
.wrapper>.aside{ | ||
width: 200px; | ||
height: 150px; | ||
background: red; | ||
float: left; | ||
margin-left: -100%; | ||
} | ||
.wrapper>.extra{ | ||
width: 200px; | ||
height: 150px; | ||
background: yellow; | ||
float: left; | ||
margin-left: -200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header">header</div> | ||
<div class="wrapper"> | ||
<div class="middle"> | ||
<div class="main">main</div> | ||
</div> | ||
<div class="aside">aside</div> | ||
<div class="extra">extra</div> | ||
</div> | ||
<div class="footer">footer</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | ||
<title>利用双飞翼布局实现两栏布局</title> | ||
<style> | ||
html,body,div{ | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
.header,.footer{ | ||
height: 40px; | ||
background: rgb(204,204,204); | ||
} | ||
.wrapper:after{ | ||
content: ""; | ||
display: block; | ||
clear: both; | ||
} | ||
.wrapper>.middle{ | ||
width: 100%; | ||
float: left; | ||
} | ||
.wrapper>.middle>.main{ | ||
height: 150px; | ||
margin-right: 200px; | ||
background: green; | ||
} | ||
.wrapper>.extra{ | ||
width: 200px; | ||
height: 150px; | ||
background: yellow; | ||
float: left; | ||
margin-left: -200px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header">header</div> | ||
<div class="wrapper"> | ||
<div class="middle"> | ||
<div class="main">main</div> | ||
</div> | ||
<div class="extra">extra</div> | ||
</div> | ||
<div class="footer">footer</div> | ||
</body> | ||
</html> |