Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am working on a site and I'm curios on the functionality of cascade style sheets. I have an image and I want other elements to appear on it when the user hovers.
e.g. A plain image, when user hovers over it I want to display two buttons on it

CSS
.image
    {
    background image: url;
    }

.image:hover
    {
    .buttonNext
        {
        backgroun-image: url;
        margin: 5px;
        }

    .buttonPrevious
        {
        backgroun-image: url;
        margin: 10px;
        }
    }

Is this even possible or should I look into CSS nesting and grouping?
Posted

1 solution

No, this is not how CSS is designed.

Yes, they are cascade, but not in this sense. CSS styles are put just in a flat single-level list.

"Cascadeness" comes from the hierarchy of elements in HTML, their parent-child relationship, not CSS. One basic principle is this: "Parent inheritance: If a property is not specified, it will be inherited from a parent element". Can you see how it cascades due to this fact? You can find other detail on style priority scheme here: http://en.wikipedia.org/wiki/CSS#CSS_Priority_scheme_.28highest_to_lowest.29[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900