div 背景颜色,改变悬停 [英] div background color, to change onhover

查看:40
本文介绍了div 背景颜色,改变悬停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在鼠标悬停时更改 div 的背景颜色.

I'm trying to make a div's background color change on mouse over.

div {background:white;}
div a:hover{background:grey;宽度:100%;
显示:块;文字装饰:无;}

the div {background:white;}
the div a:hover{background:grey; width:100%;
display:block; text-decoration:none;}

div 内的链接获得背景颜色.

我该怎么做才能使整个 div 获得那种背景颜色?

谢谢


我怎样才能让整个 div 充当一个链接——当你点击那个 div 上的任何地方时,把你带到一个地址.

EDIT :
how can I make the whole div to act as a link - when you click anywhere on that div, to take you to an address.

推荐答案

a:hover"字面意思是告诉浏览器更改 -tag,当鼠标悬停在它上面时.您的意思可能是the div:hover",它会在选择 div 时触发.

The "a:hover" literally tells the browser to change the properties for the <a>-tag, when the mouse is hovered over it. What you perhaps meant was "the div:hover" instead, which would trigger when the div was chosen.

只是为了确保,如果你只想改变一个特定的 div,给它一个 id ("<div id='something'>") 并使用 CSS "#something:hover {...}".如果要编辑一组 div,请将它们变成一个类 ("<div class='else'>") 并使用 CSS ".else {...}" 在这种情况下(注意类名前的句点!)

Just to make sure, if you want to change only one particular div, give it an id ("<div id='something'>") and use the CSS "#something:hover {...}" instead. If you want to edit a group of divs, make them into a class ("<div class='else'>") and use the CSS ".else {...}" in this case (note the period before the class' name!)

这篇关于div 背景颜色,改变悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆