开发者

css help - multiple rules

开发者 https://www.devze.com 2023-01-23 22:01 出处:网络
The hover rules are not being applied. When I view in firebug it doesn\'t seam to load the rule at all.

The hover rules are not being applied. When I view in firebug it doesn't seam to load the rule at all.

What is the correct way to implement the hover below?\

The html markup is:

<li cla开发者_如何学运维ss="ui-menu-item" role="menuitem"><a target="_blank" title="Click here" href="http://........" class="ui-corner-all" tabindex="-1">
<span class="apptitle">Some Text here</span>
<br>
<span class="descrip">Some Description</span>
</a>
<a target="_blank" href="http://......" class="ui-corner-all" tabindex="-1"><img src="someimg.gif">Please click here for support</a>     
<hr align="center" width="80%"></li>

Thanks

* html .ui-autocomplete {
width: 400px;
height: 200px;
}
.apptitle, .apptitle a, .apptitle a:active, .apptitle a:visited {
color: #0080FF;
font-weight: bold;

}
 .apptitle a:hover{
text-decoration: underline; 
}
.title {
text-align: left;
}
.descrip, .descrip a, .descrip a:active, .descrip a:visited {
padding-left: 10px;
padding-top: 10px;
text-align: left;
color: #000000
}
.descrip a:hover{
 color: #FF6600
}


Rewriting your codes for sake of simplicity first.

HTML

<li class="ui-menu-item" role="menuitem">
    <a href="xxx" class="ui-corner-all">
        <span class="apptitle">Some Text here</span>
        <br>
        <span class="descrip">Some Description</span>
    </a>
    <a href="yyy" class="ui-corner-all" tabindex="-1">
        <img src="someimg.gif">
        Please click here for support
    </a>
    <hr align="center" width="80%">
</li>

CSS

* html .ui-autocomplete {width: 400px; height: 200px;}

.apptitle, .apptitle a, .apptitle a:active, .apptitle a:visited {
color: #0080FF;font-weight: bold;
}
 .apptitle a:hover {text-decoration: underline;}

.title {text-align: left;}

.descrip, .descrip a, .descrip a:active, .descrip a:visited {
padding: 10px 0px 0px 10px; text-align: left; color: #000000
}

.descrip a:hover {color: #FF6600;}

OK, now we can analyze it.

For your hovers, you are using:

.apptitle a:hover {}
.descrip a:hover {}

However, in the HTML structure we see the apptitle is a span inside a link, and without any inside it, thus the rule will not work.

You can use

.apptitle:hover

directly, fetching the hover on span tag. This works well with all major browsers, expect IE6, and dunno about IE7. IE8+ works fine.

Or alternatively you can use:

a:hover .apptitle {}

This ensure the rules will apply only to span at link hover.

In a last word: the problem was in your selectors. Hope you enjoy the solutions.


There are the correct order for :link pseudo-class:

a:link {color:#FF0000} /* unvisited link / a:visited {color:#00FF00} / visited link / a:hover {color:#FF00FF} / mouse over link / a:active {color:#0000FF} / selected link */

If you show us the markup, maybe we can help u more quickly.

=D


Without seeing the markup I suspect you have the class of the anchor in the wrong position try

a.descrip:hover {
  color: #FF6600}

This is for markup like this

<a href="#" class="descrip">

Your CSS is for something like

<div class="descrip"><a href="#">

if this is what the markup is like try

div.descrip a:hover { ...
0

精彩评论

暂无评论...
验证码 换一张
取 消