Solved

Stacking css pseudo class selectors and pseudo elements

Posted on 2015-02-22
5
97 Views
Last Modified: 2015-02-26
Hey Experts,
I'm wondering how "stackable" css class selectors and pseudo elements are. For example, I'm trying to have a hover effect on selected text. This fiddle has a simple example: http://jsfiddle.net/3nfj6Ltv/
The desired effect in this case would be the background color of the selected text to be orange and the text color to be green, but then on hover the text color changes to red. However, in my example the text stays red. Is this possible with css alone, or would I have to use Javascript/jQuery? I imagine that event handlers would make this easier.
I've never tried to do anything like this before, but anything for the client, am I right? Haha.
Thanks!
0
Comment
Question by:Mikkel Sandberg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 40625365
I doubt you're going to get consistent results using this. The selection pseudo element was discussed and considered for CSS3, but then dropped, so it's not an official part of CSS anymore. It may work partly in some browsers, and not at all in others. Use at you own risk. Your code, for example, doesn't work at all in FireFox!!

As for generally stacking classes and pseudo elements, they're as stackable as you want them to be.
0
 
LVL 6

Author Comment

by:Mikkel Sandberg
ID: 40626036
So using Javascript may be the way to go in this instance? Or is there some other CSS trickery I can use to accomplish this?
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 40626112
I'm not aware of any CSS that can do what you're after.

As for JS, I'm sure it can be done. There's probably already code out there, or even a plugin for something like jQuery. You may need to build your own solution.

Not much more I can say really...
0
 
LVL 6

Author Comment

by:Mikkel Sandberg
ID: 40626155
Ok. I'll give it another day to see if anyone else has input. Otherwise, I'll give you all the points and close out this question.
0
 
LVL 6

Author Comment

by:Mikkel Sandberg
ID: 40634005
I meant to do this sooner, but I'm closing this out.
Thanks Chris!
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question