出於某種原因,每當我的網頁在一定的大小範圍內,導航欄中的單詞移動到不同的位置,我不知道爲什麼。爲什麼我的導航按鈕錯誤地對齊列表內部?
要看我在說什麼,看看我的代碼on jsFiddle。 將結果窗口拉伸至左側並觀察li
按鈕。
HTML:
<head>
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
</head>
<header class="row">
<a name="home"></a>
<div class="container">
<figure class="col-lg-12"><a href="index.html"><img src="assets/karate-kick.png" height="100" width="400" alt="karate kick"></a></figure>
<nav>
<ul class="col-lg-7">
<li class="col-md-2"><a href="#about">About</a></li>
<li class="col-md-2"><a href="#contact">Contact</a></li>
</ul>
</nav>
</div>
</header>
CSS:
nav ul.col-lg-7 {
text-decoration:none;
float:right;
position: relative;
}
nav ul li.col-md-2 {
list-style-type: none;
font-size: 2rem;
background-color: white;
color:black;
border: 3px outset lightgray;
margin: 8rem 0 1rem 1rem;
float:left;
bottom: 5rem;
border-radius: 25px;
text-align: center;
box-shadow: 100px black;
padding: 0 5rem;
}
nav ul li.col-md-2:active {
border: 3px inset lightgrey;
position: relative;
}
nav ul li.col-md-2:hover {
background-color:yellow;
}
header div.container {
background-color: red;
}
div figure {
top: 6rem;
}
放入保證金:8rem 0 1rem 1rem;進入nav ul.col-lg-7聲明 – jeff
以某種方式** jeff **是對的:[請參閱此處的JsFiddle的修改版本](https://jsfiddle.net/LoicMars/t7sunb6j/2/) – LoicTheAztec
@凱爾結帳我的回答 – AVI