【发布时间】:2019-05-20 19:53:33
【问题描述】:
.topnavigatiebar {
width: 1500px;
height: 100px;
background-color: #fafafa;
position: fixed;
top: 0;
overflow: hidden;
z-index: 9;
white-space: nowrap;
}
.topnavigatiebar img {
float: left;
}
.topnavigatiebar #nav {
width: 80%;
height: 50%;
margin-top: 25px;
margin-left: 20px;
float: left;
display: block;
text-decoration: none;
text-align: center;
}
.topnavigatiebar #nav #sector {
width: auto;
height: 75%;
float: left;
margin: 0 15px 0 15px;
padding: 5px 10px 5px 10px;
border-radius: 6px;
}
.topnavigatiebar #nav #sector:hover {
background-color: lightgrey;
transition: 0.25s;
}
.topnavigatiebar #nav .active {
background-color: #b7a483;
}
.topnavigatiebar #nav:visited {
color: black;
}
.topnavigatiebar #nav #sector a {
font-size: 20px;
vertical-align: center;
line-height: 40px;
text-decoration: none;
color: inherit;
}
#logo {
display: inline-block;
margin-top: auto;
height: 100%;
vertical-align: middle;
}
#logo img {
background: #3A6F9A;
vertical-align: middle;
max-height: 100px;
max-width: 100px;
border-radius: 45px;
}
.right {
float: right;
}
<div class="topnavigatiebar">
<a href="website.php"><img src="https://imgur.com/trhdmMX"></a>
<div id="nav">
<div id="sector"><a href="website.php">Home</a></div>
<div id="sector" class="active"><a href="website.php">KlantenInformatie</a></div>
<div id="sector"><a href="website.php">Artikelen</a></div>
<div id="sector"><a href="website.php">Instellingen</a></div>
<div class="right">
<div id="sector"><a href="website.php">Afmelden</a></div>
</div>
</div>
<div id="logo"><img src="../Includes/Pictures/ProfielLogo.png"></div>
</div>
所以我找不到我的问题的具体答案,但我的 html 中出现了问题。
我尝试将图像垂直对齐到导航栏的中心。图片是个人资料图片,所以你可以看到谁登录了(登录配置还没有,但那是以后的事了)。
谁能看看我的代码并告诉我我做错了什么?
这可能很简单,我愚蠢到可以忘记,但我就是想不通?
我已经尝试过这些方法,但它们并没有解决我的问题:
How to vertically align an image inside a div?
facebook photo/ image vertical align?
编辑:这里有两个图片链接:
【问题讨论】:
-
有没有在线网址可以看到你的页面?
-
它在我的笔记本电脑上是本地的,所以没有。
-
如果你要照片我可以给你吗?
-
尝试在 css 中的
#logo img中添加margin-top: 20% -
@Waleed Iqbal 如此简单!,成功了! :D
标签: css html vertical-alignment