我在 div 的结束标记之前有一个水平无序列表。该列表被放置在边界处。现在我尝试将 border-bottom: 1.5px solid #b9b7b7;
添加到 div,列表从边界向上移动,就好像 div 底部边界和列表,但我的 CSS 中没有这样的填充。我该怎么做才能将底部边框添加到父 div,并且仍然将最后一个子元素放在父 div 的底部边界?
编辑: html
<div id="banner"><img src="images/banner.gif" width="450px" height="80px" alt="parul library" />
<div id="navigation_panel">
<ul id="buttonlist">
<li class="navbuttons">Home</li>
<li class="navbuttons">About us</li>
<li class="navbuttons">New Releases</li>
<li class="navbuttons">Catalogue</li>
<li class="navbuttons">Locate us</li>
<li class="navbuttons">Contact us</li>
</ul>
</div>
</div>
CSS:
.navbuttons{
display:inline-block;
padding-left:15px;
padding-right:15px;
padding-top:5px;
padding-bottom:5px;
height:30px;
font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;
font-weight:bold;
font-size:18px;
color:#FFF;
background: rgb(110,156,183); /* Old browsers */
background: -moz-linear-gradient(top, rgba(181,221,244,1) 0%, rgba(110,156,183,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,221,244,1)), color-stop(100%,rgba(110,156,183,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(181,221,244,1) 0%,rgba(110,156,183,1)) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(181,221,244,1) 0%,rgba(110,156,183,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(181,221,244,1) 0%,rgba(110,156,183,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(181,221,244,1) 0%,rgba(110,156,183,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5ddf4', endColorstr='#6e9cb7',GradientType=0 ); /* IE6-9 */
}
#banner{
margin-top:0;
border-bottom: 1.5px solid #b9b7b7;
}
最佳答案
将您发布的 HTML/CSS 粘贴到 JS Fiddle 后,似乎在 #banner
和 上设置了
似乎将按钮放在 padding: 0;
ul
和 .navbuttons
元素上的 margin: 0#banner
的底部边缘元素:
ul,
ul li.navbuttons {
margin: 0;
}
#banner{
/* your other CSS */
padding: 0;
}
关于css - 将水平列表放在 div 的底部边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12887012/