Comments (5)
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.
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:
- http://www.davidfusilier.com/writing/specificity-and-utility-classes
- https://css-tricks.com/when-using-important-is-the-right-choice/#article-header-id-0
- https://stackoverflow.com/a/3706876
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.
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.
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.
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 !important
s 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)
- content list HOT 4
- Profile section HOT 5
- provide support for styling html meter and progress tags
- Any unofficial successor going on? HOT 5
- Radio buttons are cut off HOT 2
- Feature request add hover to the button HOT 7
- Feature request: dialog box shadow (dark mode) HOT 2
- Adding dark mode and improved UI HOT 6
- Issues being spammed with "Assign this to me" comments? HOT 4
- Ugly thing on text areas HOT 3
- This repository is not currently being maintained HOT 4
- Missing Header and Footer HOT 7
- The header of the page can be improved to a great extend..
- The header of the page can be designed to a great extend and needs some margin in the bottom HOT 2
- Add a custom 404 error page HOT 9
- Possible improvements in UI
- Fix the broken URL HOT 3
- Enhancement : Back To Top Button
- Irregular size of SUBMIT and RESET button
- The inline quotation element "q", should not be formatted the same as the "blockquote" element.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from water.css.