css,li前设置不同的图片,可是出来的结果前面的图片还是最开始设置的都一样

c15565983398 2022-10-26 21:05:31
<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title></title>
	<style type="text/css">
		ul,li{padding: 0;margin: 0;}
		li{list-style: none;
		width: 150px;height: 50px;
		background:#613E72 url(icon.png)
		no-repeat 5px center;margin:10px 30px;
		padding-left:35px;
		color:white;line-height:50px;font-weight:}
	
		.one{background-color: white;
		color:#613E72  url(clock.png)
		 no-repeat 5px center;margin:10px 30px;}
		.six{background-color: white;
		color: #613E72 url(back.png) 
		no-repeat 5px center;margin:10px 30px;}
		li:hover{background-color: yellow;}
		ul{width: 250px;border: solid 5px #613E72;}
		a:link,a:visited{color: black;text-decoration: none;}
		a:hover{background-color: yellow;text-decoration-skip: underline;}
	</style>
	</head>
	<body>
		<ul>
			<li class="one">7月30日0:00开团</li>
			<li>新品团</li>
			<li>尝鲜团</li>
			<li>秒杀团</li>
			<li>清仓团</li>
			<a href="01"><li class="six">返回顶部</li></a>
		</ul>
		<hr/>
	</body>
</html>

 

...全文
2456 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
陈树熊 2022-11-06
  • 打赏
  • 举报
回复

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8">
    <title></title>
    <style type="text/css">
        li,ul{margin:0;padding:0;}
        li{margin:10px 30px;padding-left:35px;width:150px;height:50px;background:#613e72 url(icon.png) no-repeat 5px center;color:#fff;list-style:none;line-height:50px;}
        body .one{margin:10px 30px;background:#613e72 url(clock.png) no-repeat 5px center;}
        body .six{margin:10px 30px;background:#613e72 url(back.png) no-repeat 5px center;}
        li:hover{background-color:#ff0;}
        ul{width:250px;border:solid 5px #613e72;}
        a:link,a:visited{color:#000;text-decoration:none;}
        a:hover{background-color:#ff0;text-decoration-skip:underline;}
    </style>
    </head>
    <body>
        <ul>
            <li class="one">7月30日0:00开团</li>
            <li>新品团</li>
            <li>尝鲜团</li>
            <li>秒杀团</li>
            <li>清仓团</li>
            <a href="01"><li class="six">返回顶部</li></a>
        </ul>
        <hr/>
    </body>
</html>

你样式写错了。

color:#613e72 url(clock.png) no-repeat 5px center;
修改为
background:#613e72 url(clock.png) no-repeat 5px center;

  • 打赏
  • 举报
回复

设置一个li公用的class,该class里包含除background-image以外的所有样式,让所有li元素包含该样式,然后可以通过class:nth-child(0),class:nth-child(1)...单独设置background-image

c15565983398 2022-10-26
  • 打赏
  • 举报
回复 1

请问怎么弄的,一个li单独弄一个太麻烦了,只需要改两个,有什么好的办法吗?

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧