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

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

问题描述

我试图做一个 div的背景颜色鼠标换过来

在div {背景:白色;}结果
  在div:悬停{背景:灰色;宽度:100%;结果
  显示:块;文字修饰:无;}

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

链接在div 获取背景颜色即可。

only the link inside the div gets the background color.

我能做什么使 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> - 标记,当鼠标悬停在它。你也许想的是在div:悬停来代替,这时候被选为在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.

只是为了确保,如果你想改变只有一个特定的分区,给它一个id(&LT; D​​IV ID ='东西'&GT; )和使用CSS #something:悬停{...} 来代替。如果你想编辑组div的,使它们成为一个类(&LT; D​​IV CLASS ='其他'&GT; ),并使用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!)

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

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