gpt4 book ai didi

html - 导航列表 a :hover

转载 作者:行者123 更新时间:2023-11-28 12:58:08 28 4
gpt4 key购买 nike

我正在创建一个网站,目前它的导航栏位于“ build 中”。我想要它,所以当我将鼠标悬停在它上面时,整个 nav ul li 背景都会改变颜色,而不仅仅是文本后面的背景。我有这个:

<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
<title>Landstown High School and Technology Academy - Home</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<header>
<nav>
<ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Sharepoint</a></li>
<li><a href="#">Employees</a></li>
</ul>
</nav>
</header>
<section class="body">
</body>
</html>

这是 CSS:

body
{
margin: 0;
padding: 0;
font-family: 'Noto Sans', sans-serif;
background: #F8F8F8

}

/****HEADER STUFF****/

header
{
position: fixed;
height: 10%;
width: 200%;
background: #F8F8F8;
box-shadow: -10px 0px 10px #000;
}

nav
{
margin-right: 7%;
margin-left: 7%;
height: 40px;
}

nav a:hover
{
background: #00248F;
}

nav ul
{
width: 40%;
background: #0033CC;
line-height: 40px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}

nav ul li
{
display: inline;
padding: 8%;
}

nav ul li a:hover
{
text-decoration: none;
}

nav ul li a
{
color: #F8F8F8;
text-decoration: none;
}

nav ul li a:visited
{
text-decoration: none;
}

我该怎么做?

最佳答案

试试这个:http://jsfiddle.net/3BBe2/2/ .我已经修改了你的代码。

新的 CSS:

    body
{
margin: 0;
padding: 0;
font-family: 'Noto Sans', sans-serif;
background: #F8F8F8

}

/****HEADER STUFF****/

header
{
position: fixed;
height: 10%;
width: 200%;
background: #F8F8F8;
box-shadow: -10px 0px 10px #000;
}

nav
{
margin-right: 7%;
margin-left: 7%;
height: 40px;
}

nav ul a{
padding:3px 3px;
}

/* nav li a:hover
{
background: #00248F;
} */

nav ul
{
width: 60%;
background: #0033CC;
line-height: 40px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}

nav ul li
{
display: inline;
padding: 8%;
padding:5px 5px;
padding:10px 12px 10px;
}

nav ul li:hover
{
background: #00248F;

}

nav ul li a
{
color: #F8F8F8;
text-decoration: none;

}

nav ul li a:visited
{
text-decoration: none;
}

关于html - 导航列表 a :hover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16375495/

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