GithubHelp home page GithubHelp logo

Comments (5)

joplomacedo avatar joplomacedo commented on August 26, 2024 3

This would be a perfect place to use the new :where selector. Something like:

input:where(:not([type='checkbox']):not([type='radio'])) { ... }

:where() and whatever is included inside the :where() are ignored in the specificity calculation. So effectively that line above would have the same specificity as just input

The bad news is that it's still only supported in safari and firefox's dev browsers.

from water.css.

kylejrp avatar kylejrp commented on August 26, 2024

I think this is a necessary evil of water.css. The closest I can get to lowering the specificity is:

input:not([type='checkbox']):not([type='radio']),
select {
  display: block;
}

or

input,
select {
  display: block;
}

input[type='checkbox'],
input[type='radio']{
    display: inherit;
}

Both of these still have a higher specificity than .hidden because they're targeting both input and [type=...]. I've seen other frameworks fix this by using a .check and/or .radio class... but we're a classless framework!

If anyone has a suggestion on how to fix this, I'd love to see a pull request for it! Low specificity isn't an explicit goal of water.css, but it would help with our compatibility with other css.


@frontendmonster, I hate suggesting the use of !important, but a utility class feels like an okay place to use it:

Changing the .hidden class to use display: none !important feels okay here and would solve the specificity issue while we think about thinks on our end.

from water.css.

ASafaeirad avatar ASafaeirad commented on August 26, 2024

Thanks for your fast response,
I opened #82, that can fix the issue.
Maybe that's a cheat, but i don't think so that makes problem in water.css use-cases.

from water.css.

kcclemo avatar kcclemo commented on August 26, 2024

Not sure if this might be too specific, or have any other implications but, what if you excluded inputs that contain classes or ids? This allows the water.css styles to be a baseline, but, then immediately overridden if a class or id is provided.
input:not([type='checkbox']):not([type='radio']):not([class=]):not([id=])

What I don't like about this is that if I am adding an ID or Class for the purpose of using JavaScript and not style, then I've stripped the water.css styles unnecessarily.

from water.css.

rubissima avatar rubissima commented on August 26, 2024

I've been looking into this, because it's just the kind of nerdery that I enjoy. Or at least love to hate.

I experimented with something I found here: https://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/, which was new to me: if you double the class name, you get double the specificity. So .hidden.hidden is twice as specific as .hidden, .hidden.hidden.hidden is 3x the specificity, etc.

Incidentally, I inspected this very page to test it, and found no less than five !importants in the css attached to a single element. Two of them were in a media query and cancelled out two other ones. This, I believe, is the danger of !important.

from water.css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.