1

我很难弄清楚如何将文本的底部边框与标题的底部边框对齐。谁能告诉我该怎么做?将不胜感激。我已经尝试了很多东西。

http://jsfiddle.net/Zevoxa/YeJc6/

HTML

<div id="header">
    <img id="logo" src="/img/logo.png"/>
    <div id="nav">
    <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
    </ul>
    </div>
</div>

CSS

/*-- HEADER --*/

#header {
 top:0px;
 width:100%;
 padding-top:20px;
 padding-bottom:0px;
 background-color:#2C2E31;
 border-bottom:#242426 solid 2px;
 text-align:center;
}

img#logo {
 margin-left:auto;
 margin-right:auto;
 margin-bottom:20px; 
}

#nav ul li {
 list-style-type:none;
 display:inline;
 margin-bottom:0px;
 padding-bottom:0px;
 padding-right:20px;
 font-size:20px;


}

#nav ul li a {
 color:#FAFAFA;
 text-decoration:none;
 border-bottom:#FAFAFA solid 2px;
}

/*-- CONTENT --*/

body {
 margin:0px;
 padding:0px;
 background-color:#2A2B2D;
}
4

3 回答 3

1

您可以将 ul 的 margin-bottom 设置为 0px

    #header ul {
        margin-bottom:0px;
    }

http://jsfiddle.net/YeJc6/6/

于 2013-06-16T02:29:54.670 回答
0

可以简单地将#nav 设置为#header 的底部:

#nav
{
position:absolute;
bottom:0px;
height:20px;    //whatever height/size of text is needed
}

这告诉它将#header 中的#nav 对齐到#header 的底部。

于 2013-06-16T02:20:01.087 回答
0

在您的情况下,您只需要删除 ul 的底部边距。

#nav ul {
    margin-bottom: 0;
}
于 2013-06-16T02:27:10.477 回答