我正在嘗試爲我的網站創建標題。我想讓我的標誌位於窗口的左上角,導航欄位於窗口的右上角。我的問題是,導航欄不與我的標誌中心齊平。這裏的商品:如何在使用Bootstrap時將文本與圖像中心垂直對齊。
#logoHeader {
\t float: left;
\t vertical-align: middle;
}
ul {
\t list-style: none;
\t display: inline block;
\t vertical-align: middle;
}
li {
\t float: right;
\t padding: 10px;
\t font-size: 22pt;
\t display: inline-block;
}
.header .navContainer {
\t height: 131px;
\t vertical-align: middle;
}
<!DOCTYPE html>
<html>
<head>
\t <meta charset = "utf-8">
\t <meta name="viewport" content="width=device-width, initial-scale=1">
\t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
\t <link type= "text/css" rel="stylesheet" href="all.css"/>
\t <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
\t <script type = "text/javascript" src = "index.js"></script>
\t
\t <title>JM</title>
</head>
<body>
<div class ="container">
\t <div class="row">
\t <div class="col-md-4 header">
\t <img id = "logoHeader" src="file:///Users/Jon/Desktop/JM.COM/images/bigJM.png"/>
\t </div>
\t <div class="cold-md-8 navContainer">
<ul class = "navBar">
\t <li>Home</li>
\t <li>Blog</li>
\t <li>Publications</li>
\t <li>Contact</li>
</ul>
\t </div>
\t </div>
</div>
</body>
</html>
這個線程可以幫助你http://stackoverflow.com/questions/34912881/how-to-vertically-align-a-div-using-css/ – Mystika