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

查看:36
本文介绍了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"字面上告诉浏览器更改<a>-tag,当鼠标悬停在它上面时.您的意思可能是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天全站免登陆