[英]How could I get the buttons on the left?
我正在嘗試創建參考網站。 我正在使用稱為“ Skel”的新框架。 它確實很酷,但是沒有特定的文檔。 我想知道如何使導航欄上的按鈕位於標題旁邊,而不是右側。 這是我正在使用的代碼:
<header id="header" class="skel-layers-fixed">
<h1><a href="#">Reference</a></h1>
<nav id="nav">
<ul>
<li><a href="#top">Top</a></li>
<li><a href="index.html">Home</a></li>
<li><a href="page2.html">References</a></li>
<li><a href="page3.html">About</a></li>
</ul>
</nav>
</header>
這是style.css中導航欄的內容
#header nav {
height: inherit;
line-height: inherit;
position: absolute;
right: 1.25em;
top: 0;
vertical-align: middle;
}
#header nav > ul {
list-style: none;
margin: 0;
padding-left: 0;
}
#header nav > ul > li {
border-radius: 4px;
display: inline-block;
margin-left: 1em;
padding-left: 0;
}
#header nav > ul > li a {
-moz-transition: color 0.2s ease-in-out;
-webkit-transition: color 0.2s ease-in-out;
-o-transition: color 0.2s ease-in-out;
-ms-transition: color 0.2s ease-in-out;
transition: color 0.2s ease-in-out;
color: #ccc;
display: inline-block;
text-decoration: none;
}
#header nav > ul > li a:hover {
color: #fff;
}
#header nav > ul > li:first-child {
margin-left: 0;
}
#header nav > ul > li .button {
height: 2.25em;
line-height: 2.25em;
margin-bottom: 0;
padding: 0 1em;
position: relative;
top: -0.075em;
vertical-align: middle;
}
#header .container {
position: relative;
}
#header .container h1 {
left: 0;
}
#header .container nav {
right: 0;
}
您將需要稍微修改CSS。 首先,為標題內的標題指定以下樣式:
#header h1 {
display: inline-block;
margin: 0px;
vertical-align: middle;
}
指定要display
的h1
的display
屬性display: inline-block
允許其他元素出現在與標題相同的行中。
接下來,您將需要刪除用於#header nav
現有CSS,並使用以下樣式:
#header nav {
display: inline-block;
vertical-align: middle;
}
這是一個工作示例:
#header nav { display: inline-block; vertical-align: middle; } #header h1 { display: inline-block; margin: 0px; vertical-align: middle; } #header nav > ul { list-style: none; margin: 0; padding-left: 0; } #header nav > ul > li { border-radius: 4px; display: inline-block; margin-left: 1em; padding-left: 0; } #header nav > ul > li a { -moz-transition: color 0.2s ease-in-out; -webkit-transition: color 0.2s ease-in-out; -o-transition: color 0.2s ease-in-out; -ms-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out; color: #ccc; display: inline-block; text-decoration: none; } #header nav > ul > li a:hover { color: #fff; } #header nav > ul > li:first-child { margin-left: 0; } #header nav > ul > li .button { height: 2.25em; line-height: 2.25em; margin-bottom: 0; padding: 0 1em; position: relative; top: -0.075em; vertical-align: middle; } #header .container { position: relative; } #header .container h1 { left: 0; } #header .container nav { right: 0; }
<header id="header" class="skel-layers-fixed"> <h1><a href="#">Reference</a></h1> <nav id="nav"> <ul> <li><a href="#top">Top</a> </li> <li><a href="index.html">Home</a> </li> <li><a href="page2.html">References</a> </li> <li><a href="page3.html">About</a> </li> </ul> </nav> </header>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.