/    Sign up×
Community /Pin to ProfileBookmark

Same hover color on 2 elements with different hover color

Hello guys, I’m having troubles in templating the design for one of our clients. attached is the design. The designer wants the <h2> <p> and the image to all have the same color when hovered. Problem is that <h2> and <p> have different styles, disabling my declared hover color.


———————————————————–

this sample code below is similar the .h-links li:hover is set to blue, but wont take effect.

[QUOTE]

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>

<style type=”text/css”>
body {
background-color:#fff;
text-align:center;
margin:auto;padding-top:50px;
font-family: tahoma, “Helvetica Neue”, Helvetica, Trebuchet MS, “Lucida Grande”, sans-serif;
}
.h-links li:hover{
background: #eee;
color: blue;
}

.h-links {
font-size:0.75em;
text-align:left;
width:450px;
padding:0; margin:0 auto;
border:dotted #777;
border-width:1px 0px 0px 0px ;
color:#222;
}

.h-links ul {
list-style-type: none;
width:450px;
margin:0; padding:0;
}

.h-links li {
border-bottom:1px dotted #777;
}

.h-links span{
font-size:0.75em;
color:#777;
font-weight:normal;
}

.h-links p{
margin:5px 0 0 0; padding:0;
color:#000;
font-weight:normal;
}

.h-links li a {
color: #CC0033;
text-decoration: none;
font-weight:600;
display:block;
padding: 15px 15px 15px 10px;
}

</style>

<title>Links Hover Example – Final</title>
</head>

<body>

<div class=”h-links”>

<ul>

<li>
<a href=”http://www.bloggingtips.com/2008/07/12/reduce-your-code/” rel=”bookmark” title=”Permanent Link: Reduce your code.”>
Reduce your code. <span>12 Jul 2008</span>
<p>Complex designs are quite often a mess of div’s and span’s, it’s not surprising some people are sticking to tables, but unless they have a time machine tables are not the answer, remember it’s CSS or die!</p> </a>
</li>

<li>
<a href=”http://www.bloggingtips.com/2008/07/05/use-css-to-style-links/” rel=”bookmark” title=”Permanent Link: Use CSS to Style Link Types.”>
Use CSS to Style Link Types. <span>05 Jul 2008</span> <br/>
<p>Ever wanted to style your links to represent the type of content it links too without having to add a class to each link? Well I’m here again to save the day with a no brainier solution. This is quick and simple so I’ll get right too it.</p></a>
</li>

<li>
<a href=”http://www.bloggingtips.com/2008/06/28/fancy-forms/” rel=”bookmark” title=”Permanent Link: Fancy Forms”>
Fancy Forms <span>28 Jun 2008</span></a>
</li>

<li>
<a href=”http://www.bloggingtips.com/2008/06/21/columns-dropping-off/” rel=”bookmark” title=”Permanent Link: Columns dropping off”>
Columns dropping off <span>21 Jun 2008</span></a>
</li>

<li>
<a href=”http://www.bloggingtips.com/2008/06/14/accessibility-checklist/” rel=”bookmark” title=”Permanent Link: Accessibility Checklist”>
Accessibility Checklist <span>14 Jun 2008</span> </a>
</li>

</ul>

</div>

</body>
</html>

[/QUOTE]

[upl-file uuid=d67afefb-47ac-43c6-8dd3-8f2003354726 size=37kB]Capture.JPG[/upl-file]

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@Frank62Jul 31.2011 — the .h-links li:hover is set to blue, but wont take effect[/QUOTE]

Which is logical, because with more specificity you are declaring text colors for the href, span and p. Those colors overrule the general color of the li, which extends to the hover event.

I'd think it cannot be done regarding the href. It could be done for the rest of the text, if you let them inherit their color from the li.
Copy linkTweet thisAlerts:
@Cory_RAug 01.2011 — .h-links li:hover &gt; a {
color: blue;
}
That will designate the hyperlink hover.
Copy linkTweet thisAlerts:
@Frank62Aug 01.2011 — @Cory:

You're right. I forgot about that, probably because I haven't used it yet. Is that rendered cross-browser already (no need for IE6)?
Copy linkTweet thisAlerts:
@Cory_RAug 02.2011 — The child selector is supported in IE7+ and all other major browsers.
×

Success!

Help @amanoyuuji spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...