gpt4 book ai didi

html - CSS:导航栏中的另一个按钮

转载 作者:太空宇宙 更新时间:2023-11-04 02:40:16 26 4
gpt4 key购买 nike

这些是我的代码:

CSS

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
li {
float: left;
}

li a{
display:block;
color: white;
text-align: center;
padding: 14px 50px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #111;
}

* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-weight: 300;
}

body {
background: dimgrey;
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}
body ::-webkit-input-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}
body :-moz-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
opacity: 1;
font-weight: 300;
}
body ::-moz-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
opacity: 1;
font-weight: 300;
}
body :-ms-input-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}

HTML

<body> 
<ul>
<li><a href="home.html" target="_parent">Home</a></li>
<li><a class="active" href="log-in.html" target="_parent">Sign In/Sign Up</a></li>
<li><a href="#about">About</a></li>
<li><a href="#order">Order</a></li>
<li><a href="movies.html" target="_parent">More Movies</a></li>
<li><a href="contact.html" target="_parent">Contact</a></li>
</ul>

</body>

我想添加另一个具有不同 background-color 的按钮,并且可能会放在最右侧,与其他按钮分开。我不知道如何将它与其他按钮分开,所以我只是尝试更改它的背景。我尝试制作另一个类,因为另一个按钮将不可点击,仅用于显示,也没有悬停效果。但它仍然行不通。你能给我一些建议吗?

最佳答案

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
li {
float: left;
}

li a{
display:block;
color: white;
text-align: center;
padding: 14px 50px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #111;
}

* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-weight: 300;
}

body {
background: dimgrey;
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}
body ::-webkit-input-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}
body :-moz-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
opacity: 1;
font-weight: 300;
}
body ::-moz-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
opacity: 1;
font-weight: 300;
}
body :-ms-input-placeholder {
font-family: 'Gill Sans MT', sans-serif;
color: white;
font-weight: 300;
}
.special {
float: right;
background: red;
}
<body> 
<ul>
<li><a href="home.html" target="_parent">Home</a></li>
<li><a class="active" href="log-in.html" target="_parent">Sign In/Sign Up</a></li>
<li><a href="#about">About</a></li>
<li><a href="#order">Order</a></li>
<li><a href="movies.html" target="_parent">More Movies</a></li>
<li><a href="contact.html" target="_parent">Contact</a></li>
<li class="special"><a>special</a></li>
</ul>

</body>

这是我的解决方案,给特殊的li一个类,并设置 float 权利

关于html - CSS:导航栏中的另一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34873061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com