我是HTML和CSS的新手。我正在嘗試做一個網站,而且我從導航欄開始,但每當我嘗試做我的導航欄縮小時。導航欄HTML和CSS需要幫助
HTML
<!DOCTYPE html>
<html>
<head>
<title>Webhosting</title>
<link rel="stylesheet" type="text/css" href="cssone.css"/>
</head>
<body>
<div class="body_div">
<!--NAVBAR-->
<div class="navbardiv">
<ul class="navbar_ul">
<li class="navbar_li_Contact"><a href="#contact.html">Contact</a></li>
<li class="navbar_li_WebHosting"><a class="active" href="#index.html">Webhosting</a></li>
<li class="navbar_li_About"><a href="#about.html">About</a></li>
</ul>
</div>
<div>
</body>
</html>
CSS
body{
background-image:url(imgs/background3.jpg);
background-repeat: no-repeat;
background-attachment:fixed;
background-size: cover;
}
.navbardiv{
font-family:Rockwell;
font-size: 30px;
}
.navbar_ul{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
background-color:#333;
border-radius:5px;
border-left:2px solid white;
border-right:2px solid white;
border-top:2px solid white;
border-bottom:2px solid white;
margin: -8px;
width: auto;
min-width:416px;
height:80px;
display: flex;
justify-content: space-between;
/*position:fixed;*/
}
li {
float:left;
padding:15px 100px;
}
li a{
display:block;
color:white;
text-align:center;
padding:8px 16px;
text-decoration: none;
border:2px solid white;
/*border-bottom:2px solid white;*/
border-radius:5px;
}
li a:hover{
background-color:gray;
}
但是你在哪裏添加了100%? –
@SamuelFerreira你會將它添加到問題元素'.navbar_ul'中。我沒有使用寬度,雖然我用'左'和'右' –
我做到了,因爲你說過,但現在它隱藏了白色邊框,我試過放左:1右:1,但後來它收縮得太多 –