gpt4 book ai didi

html - 只更改一个 标签的 CSS

转载 作者:行者123 更新时间:2023-11-28 01:16:02 25 4
gpt4 key购买 nike

我的网页顶部有 3 个链接,还有一个链接嵌入到图像中。这 3 个链接的背景颜色与导航不同,但不幸的是,它还会将此添加到带有链接的图像中。如何将其从图像中删除?

html{
font-family: abel;
background-color: #a4bdd1;
margin: 0;
padding: 0;
}
body{
overflow-x:hidden;
margin: 0;
padding: 0;
}
nav {
text-align: center;
background-color: #e4e6e5;
/* position: fixed;
top: 0;
left: 0;
z-index: 9999;*/
width: 100%;
border-bottom: solid #05182e 2px;
margin-top: -1px
}
nav li {
display: inline-block;
font-size: 35px;
padding: 15px;
font-weight: bold;
vertical-align: middle;
}

nav a{
border-radius: 10%;
padding: 8px;
background-color: #cccccc;
color: #1f3b5a;
text-decoration: none;
font-size: 30px;
transition: all 0.5s ease-in-out;
}
nav a:hover{
font-size: 40px;
transition: all 0.5s ease-in-out;
}
nav img{
width: 30%;
border: none;
transition: all 0.5s ease-in-out;
}
nav img:hover{
width: 40%;
transition: all 0.5s ease-in-out;
}
ul {
margin: 0;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Bitter:700' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16" />
<title>Brampton Thunder</title>
</head>

<body>

<nav>
<ul>
<li><img src="images/logo.png" alt="Canadian Women's Hockey League Logo"></li>
<li> <a href="index.html" target="_blank">Home</a></li>
<li> <a href="roster.html" target="_blank">Roster</a></li>
<li> <a href="schedule.html" target="_blank">Schedule</a></li>
<li><a href="http://cwhl.ca" target="_blank"><img src="images/cwhllogo.png"></a></li>

</ul>
</nav>

最佳答案

你可以这样做:

nav ul li:last-child a {
background-color:#e4e6e5;
}

检查下面的片段

html {
font-family: abel;
background-color: #a4bdd1;
margin: 0;
padding: 0;
}
body {
overflow-x: hidden;
margin: 0;
padding: 0;
}
nav {
text-align: center;
background-color: #e4e6e5;
/* position: fixed;
top: 0;
left: 0;
z-index: 9999;*/
width: 100%;
border-bottom: solid #05182e 2px;
margin-top: -1px
}
nav li {
display: inline-block;
font-size: 35px;
padding: 15px;
font-weight: bold;
vertical-align: middle;
}
nav a {
border-radius: 10%;
padding: 8px;
background-color: #cccccc;
color: #1f3b5a;
text-decoration: none;
font-size: 30px;
transition: all 0.5s ease-in-out;
}
nav ul li:last-child a {
background-color: #e4e6e5;
}
nav a:hover {
font-size: 40px;
transition: all 0.5s ease-in-out;
}
nav img {
width: 30%;
border: none;
transition: all 0.5s ease-in-out;
}
nav img:hover {
width: 40%;
transition: all 0.5s ease-in-out;
}
ul {
margin: 0;
}
<nav>
<ul>
<li>
<img src="images/logo.png" alt="Canadian Women's Hockey League Logo">
</li>
<li> <a href="index.html" target="_blank">Home</a>
</li>
<li> <a href="roster.html" target="_blank">Roster</a>
</li>
<li> <a href="schedule.html" target="_blank">Schedule</a>
</li>
<li>
<a href="http://cwhl.ca" target="_blank">
<img src="images/cwhllogo.png">
</a>
</li>

</ul>
</nav>

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