我在div#链接中添加的链接越多,它相对于其他div就越高。为什么呢?
<body>
<div id="pageWrapper">
<div id="plan">
<div class="heading">
Plan
</div>
</div>
<div class="links">
<div class="heading">
Links 1
</div>
<a href="#">Link 1</a><br/>
<a href="#">Link 2</a>
</div>
<div class="links">
<div class="heading">
Links 2
</div>
</div>
<div class="links">
<div class="heading">
Links 3
</div>
</div>
<div id="notes">
<div class="heading">
Notes
</div>
</div>
<div class="links">
<div class="heading">
Links 3
</div>
</div>
<div id="gallery">
<div class="heading">
Gallery
</div>
</div>
</div><!--end pageWrapper-->
</body>
</html>
* {
margin: 0px;
padding: 0px;
border: none;
}
body {
background-color: rgb(30,30,30);
}
#pageWrapper {
width: 1200px;
height: 650px;
background-color: rgb(30,30,30);
color: rgb(230,230,230);
margin: 10px auto 0px auto;;
font-family: Tahoma, sans-serif;
font-size: 18px;
padding: 20px 0px;
}
a:link, a:visited {
color: rgb(184,216,5);
text-decoration: none;
}
a:hover, a:active {
color: rgb(184,216,5);
text-decoration: underline;
}
#plan , #notes, #gallery{
border: 3px solid rgb(230,230,230);
border-radius: 10px;
width: 452px;
height: 280px;
display: inline-block;
margin: 0px 5px 10px 5px;
}
.links {
border: 3px solid rgb(230,230,230);
border-radius: 10px;
width: 215px;
height: 280px;
display: inline-block;
margin: 0px 5px 10px 5px;
}
.heading {
width: 150px;
margin: 0px auto 5px auto;
text-align: center;
font-size: 0.8em;
}
.links a {
margin-left: 30px;
}
答案 0 :(得分:3)
将vertical-align:top
添加到.links
课程。应该使所有div对齐。
答案 1 :(得分:0)
您需要使用以下属性:
vertical-align: top;
因此,只需修改您的#plan, #notes, #gallery
和links
课程,如下所示:
#plan, #notes, #gallery {
border: 3px solid #E6E6E6;
border-radius: 10px;
width: 452px;
height: 280px;
display: inline-block;
margin: 0px 5px 10px;
vertical-align: top;
}
见以下工作:
* {
margin: 0px;
padding: 0px;
border: none;
}
body {
background-color: rgb(30,30,30);
}
#pageWrapper {
width: 1200px;
height: 650px;
background-color: rgb(30,30,30);
color: rgb(230,230,230);
margin: 10px auto 0px auto;;
font-family: Tahoma, sans-serif;
font-size: 18px;
padding: 20px 0px;
}
a:link, a:visited {
color: rgb(184,216,5);
text-decoration: none;
}
a:hover, a:active {
color: rgb(184,216,5);
text-decoration: underline;
}
#plan , #notes, #gallery{
border: 3px solid rgb(230,230,230);
border-radius: 10px;
width: 452px;
height: 280px;
display: inline-block;
margin: 0px 5px 10px 5px;
vertical-align:top;
}
.links {
border: 3px solid rgb(230,230,230);
border-radius: 10px;
width: 215px;
height: 280px;
display: inline-block;
margin: 0px 5px 10px 5px;
vertical-align:top;
}
.heading {
width: 150px;
margin: 0px auto 5px auto;
text-align: center;
font-size: 0.8em;
}
.links a {
margin-left: 30px;
}
&#13;
<body>
<div id="pageWrapper">
<div id="plan">
<div class="heading">
Plan
</div>
</div>
<div class="links">
<div class="heading">
Links 1
</div>
<a href="#">Link 1</a><br/>
<a href="#">Link 2</a>
</div>
<div class="links">
<div class="heading">
Links 2
</div>
</div>
<div class="links">
<div class="heading">
Links 3
</div>
</div>
<div id="notes">
<div class="heading">
Notes
</div>
</div>
<div class="links">
<div class="heading">
Links 3
</div>
</div>
<div id="gallery">
<div class="heading">
Gallery
</div>
</div>
</div><!--end pageWrapper-->
</body>
</html>
&#13;