为什么悬停不适用于class atribute [英] Why hover does not work with class atribute

查看:72
本文介绍了为什么悬停不适用于class atribute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了如下样式

I have created a style as following

.box
{
  height:300px;
  width:500px;
  font-size:1em;

}
.box:hover
{
  font-weight:bold;
}



我将其应用于如下范围



I applied it to a span as follows

<span class="box">Hello to world </span>


它可以正常工作,但悬停属性不起作用.
否则,如果我在CSS样式中使用#box而不是.box,然后按如下所示应用它


it works fine but the hover property does not work.
Else if, I use #box instead of .box in my css style and then Apply it as below

<span id="box">Hello to world </span>


然后,悬停属性就可以正常工作了.

我不明白为什么悬停属性不能与类属性一起使用.有人可以解决吗?


Then the hover property works fine.

I could not understand why hover property does not work with class attribute. Can some one solve it?

推荐答案


这对我来说很好.我已经用(IE:8.0,FF:6.0)测试了它
Hi,
this is works fine for me. i have tested it with (IE: 8.0, FF: 6.0)
<span class="box">Hello to world </span> 



您可以使用以下内容:



You may use following:

<style type="text/css">
        a .box
        {
            height: 300px;
            width: 500px;
            font-size: 1em;
        }
        a .box:hover
        {
            font-weight: bold;
        }
    </style>

 <a><span class="box">Hello to world </span></a>



谢谢,
Imdadhusen



Thanks,
Imdadhusen


这篇关于为什么悬停不适用于class atribute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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