css a hover 触摸屏,html - CSS a:hover inline? - Stack Overflow

本文探讨了如何使用CSS为网站导航栏按钮设置高亮显示的不同颜色。作者尝试通过内联样式及特定元素ID实现这一效果,但遇到了一些挑战。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have been trying to create a navigation bar for a website I am making, and I want each button to display a difference colour when highlighted. I have used

  • to create the navigation bar. The question is, is there a way to use the "a:hover {background:#;}" as inline CSS on a specific element?

I have tried giving each

or an id and then creating references to them in the internal style sheet, but can't get it to work. Below is what I have so far;

#menu {height:37px;display:block;margin:20px auto;border:1px solid;border-radius:5px;margin-left:30px;max-width:550px}

#menu ul {margin:0;padding:0;}

#menu li {float:left;display:block;min-width:110px}

#menu a {display:block;padding:12px;font:bold 13px/100% Arial, Helvetica, sans-serif;text-align:center;text-decoration:none;text-shadow:2px 2px 0 rgba(0,0,0, 0.8); background-color:#5A8A41;border-right:1px solid #1b313d; color:#fff;}

#menu a:hover {background:#5D80B0;}

...

Just so your aware, I have been using html and CSS for all of 1 week. So I apologise if this is a stupid question. Thanks.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值