我明明已经修改了导航栏列表中图片的长和宽,但是效果并不如意,而且用浏览器的开发工具去看的话发现还是使用的没有修改的CSS,这是怎么回事?
页面代码<%--
Created by IntelliJ IDEA.
User: xing
Date: 2023/10/22
Time: 20:24
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="style/public.css">
<body>
<header>
<div class="logo"><img src="images/logoko.png" alt=""></div>
<nav>
<ul>
<li>
<a href="index.jsp"><img src="images/index.png" alt="">首页</a>
</li>
<li>
<a href="write.jsp"><img src="images/write.png" alt="">写博客</a>
</li>
<li>
<a href="about.jsp"><img src="images/about.png" alt="">关于我们</a>
</li>
<li>
<a href="register.jsp"><img src="images/register.png" alt="">登录/注册</a>
</li>
</ul>
</nav>
</header>
</body>
</html>
对应的CSS/* 初始化设置 */
* {
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
}
/* 浮动设置 */
.leftfloat {
float: left;
}
body {
background-color: #ecf0f1;
}
header {
height: 100px;
background-color: #3498db;
position: relative;
}
header .logo {
width: 400px;
margin: 0 auto;
}
header nav {
width: 100%;
height: 30px;
background-color: #2c3e50;
position: absolute;
bottom: 0;
}
header nav a {
text-decoration: none;
color: white;
}
header nav a:hover {
color: skyblue;
font-weight: 600;
}
header nav ul li a img {
width: 20px;
height: 20px;
}
header nav ul {
position: absolute;
left: 30%;
}
header nav ul li {
display: inline-block;
width: 100px;
text-align: center;
line-height: 30px;
}
.box {
width: 800px;
min-height: 500px;
background-color: #ADD8E6;
margin: 0 auto;
padding: 20px;
}
.ad {
width: 150px;
height: 400px;
background-color: tomato;
position: fixed;
left: 0;
top: 15%;
}
.ad .x {
width: 20px;
height: 20px;
background-color: white;
position: absolute;
right: 0;
top: 0;
font-size: 20px;
line-height: 20px;
text-align: center;
cursor: pointer;
}
footer {
height: 80px;
background-color: #333333;
color: white;
padding-top: 4px;
}
footer p {
text-align: center;
line-height: normal;
font-weight: 200;
}
对应的效果图片
检查一下你的CSS文件路径是否正确,以及确保你在浏览器中清除了缓存。另外,你的CSS选择器可能存在问题,尝试使用更具体的选择器来覆盖原有样式。例如,使用更具体的选择器来修改导航栏列表中图片的长和宽,比如给img添加class或者id,并使用该class或id作为选择器。
|