我一直在亂搞我的代碼大約兩天了,我所做的一切都不起作用。我希望導航欄位於兩個元素中間(<img>, <form>
)。現在大致居中,但當您重新調整窗口大小時,它會在1600px左右混亂。它只需要工作到1500px,因爲在那之後,我要去一個不同的導航欄的位置和風格。如何將我的導航欄置於兩個不平坦元素之間?
Codepen:http://codepen.io/anon/pen/KpECd
HTML:
<header>
<img src="../Images/Logo.svg" class="logo">
<nav>
<a href="#" class="one">SHARING</a>
<a href="#" class="two">HOSTING</a>
<a href="#" class="three">PRICING</a>
<a href="#" class="four">ACCOUNT</a>
</nav>
<form method="post" action="index.php">
<button value="SIGNUP" name="signup">SIGNUP</button>
<button value="LOGIN" name="login">LOGIN</button>
</form>
</header>
CSS:
@charset "utf-8";
header {
background-color:#464646;
height:100px;
width:100%;
}
header .logo {
max-height:44px;
max-width:535px;
margin:28px 28px 28px 28px;
}
header form {
display:inline;
float:right;
margin:28px 28px 28px 28px;
}
header form button {
height:44px;
width:125px;
border:2px solid white;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
background-color:transparent;
font-family:"Lato Black";
color:white;
font-size:22px;
}
header form button:hover {
background-color:rgba(255, 255, 255, .2);
cursor:pointer;
}
header form button:active {
background-color:rgba(255, 255, 255, .8);
}
nav {
width:47.5%;
display:inline;;
position:absolute;
text-align:center;
}
nav a {
display:inline-block;
height:100px;
width:20%;
color:white;
font-family:"Lato Black";
text-decoration:none;
font-size:16px;
line-height:100px;
}
nav a:hover {
background-color:#00a651;
cursor:pointer;
}
你想要的菜單和按鈕來動態地重新定位它們自己,或者當你調整窗口的大小時,你會寧願一切都保持放置,當窗口太小時,按鈕/菜單會被切斷?如果您爲標題添加最小寬度,則可以控制窗口切換到滾動條的位置。 – sabrams 2014-10-20 17:00:14
我有所有的媒體查詢,它是動態的,但它並沒有重新調整我想要的方式。我希望導航按鈕是「流暢的」,並根據頁面大小的百分比重新調整大小。 – 2014-10-20 17:02:49