W3C home > Mailing lists > Public > www-style@w3.org > April 2014

[css-variables] Another use case for "cascade"

From: François REMY <francois.remy.dev@outlook.com>
Date: Thu, 17 Apr 2014 17:54:20 +0200
Message-ID: <DUB130-DS27AE3230C69548C88969E6A5520@phx.gbl>
To: "CSS WG" <www-style@w3.org>
Hi,

Just figured out I would have liked to have “cascade” today in the following 
case:

    button {
        background: #aaa;
        color: black;
    }

    button:hover {
        background: orange;
        color: white;
    }

    <!-- this button won't become orange on hover :( -->
    <button style="background: red; color: white;">...</button><!-- or 
#button_id { ... } -->

vs


    :hover {
        background: var(--hover-background, cascade);
        color: var(--hover-color, cascade);
    }

    button {
        background: #aaa;
        --hover-background: orange;
        color: black;
        --hover-color: white;
    }

    <!-- it will work :-) -->
    <button style="background: red; color: white;">...</button><!-- or 
#button_id { ... } -->

That's it, this is just for the record and possible later references --  
except if you have comments of course!
François

______________________
PS: Yes, I know, I can maybe use "button:hover" and accept only 
"--hover-background" for buttons, for which I know what the fallback should 
be, but that's maybe not the most elegant option, or is it? What if I don't 
want to change the background if no hover-background was specified? 
Received on Thursday, 17 April 2014 15:54:44 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:39 UTC