【发布时间】:2020-05-26 12:27:45
【问题描述】:
我的网站导航栏有问题,因为我放的徽标太宽,它会影响文本,使它们都粘在顶部我怎样才能使文本或徽标相互对齐?
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #242626;
font-family: Arial, Helvetica, sans-serif;
}
li {
float: left;
}
li a, .dropbtn {
display: inline-block;
color: #cedacb;
text-align: center;
padding: 14px 16px;
widht: 120px;
min-height: 60px;
vertical-align: top;
text-decoration: none;
}
li a:hover {
color: white;
}
<style>
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
#home {
width: 120px;
height: 60px;
background: url(https://st.deviantart.net/minish/main/logo/card_black_large.png) 0 0;
}
#logo {
float: left;
}
</style>
</style>
</head>
<body>
<ul>
<li><a href="#home"><img id="home" src="https://st.deviantart.net/minish/main/logo/card_black_large.png" alt="Logo" id="logo"></a></li>
<li><a href="#search">Search</a></li>
<li><a href="#news">Submit</a></li>
<li class="dropdown" style="float:right;">
<a href="javascript:void(0)" class="dropbtn">Notification</a>
<div class="dropdown-content" style="right:0;">
<a href="#">All Inbox</a>
<a href="#">Inbox</a>
<a href="#">Watch</a>
<a href="#">Note</a>
</div>
</li>
</ul>
</body>
</html>`
我正在开发的网站导航栏:
为了澄清一下,我不为 Deviantart 工作,我选择了用于徽标练习的图片,起初它不适合,然后我更改了代码,以便我可以使用此代码使其适合导航栏
#home {
width: 120px;
height: 60px;
background: url(https://st.deviantart.net/minish/main/logo/card_black_large.png) 0 0;
}
它把导航栏上的文字搞砸了,我该如何修复它,使它们全部对齐?
【问题讨论】:
-
最简单的解决方案是为菜单项设置
line-height: 60px -
非常感谢,它有效。
标签: javascript html jquery css twitter-bootstrap