-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.hide and .show without !important rule #9237
Comments
Could you provide a fiddle showing such a problem? |
Here is the fiddle: http://jsfiddle.net/kQ47C/ Same problem with css() and animate() jQuery functions. |
I have just encountered a small related issue with .hidden-* and .visible-* classes - they define display rule for block and table elements, however, I needed to show/hide inline elements. I came up with some custom @media rules for the template I am currently working on, however, maybe .hidden-inline-* and .visible-inline-* would be of some use to the community. |
@dantistus The docs explicitly mention that those classes use |
@cvrebert Thank you for your answer. Yeap, that's exactly what I was saying, I know it's block :) I also said it might be useful to add other similar class for inline (or inline-block) elements. That would be logical. |
We'll leave the As for additional classes, add a new issue or PR to continue those talks elsewhere. |
As an alternative to .hide one can use the attribute hidden. This works great with bootstrap and jQuery show() in all browsers from IE6 |
I've had to remove the !important rule as it was avoiding all my jquery code to make visible some components. |
Likewise causing problems for me with jQuery. This also affects jQuery animations. |
👍 That was the bootstrap 2 behavior and no reason has been provided as to why the |
The current behavior is very bad. +1 for removing the important rag. |
Not sure why the !important flag is set, but I do also have trouble with jQuery's hide() and show() functions. |
Why are any of these !important ? Since they are outside the media queries, they are important already. |
@carasmo To avoid specificity conflicts with other styles. We're thinking about changing it in v4, when we can break backward-compatibility again. |
I also believe the !important flag should be removed. We can't use jQuery .show and .hide anymore :( |
+1 ... basically nerfs all jquery animations. Going around it for now like this:
|
It is interesting to note that html5-boilerplate's |
The h5bp folks seem to recommend not mixing jQuery-based and CSS-class-based showing/hiding in the first place: h5bp/html5-boilerplate#746 |
I too believe that those
is just counter intuitive. |
"Me too", here. So what is the best way of toggling an hidden-sm div (so that I can display it) without changing my bootstrap CSS file?? I'd also like to have the user be able to re-hide it. Looks like it will be some jQuery hackery |
http://jsbin.com/IxifuQEz/1/edit?html,js,output
it's hidden-sm NOT sm-hidden. |
Workaround:
|
adding important to hide and show breaks backward compatibility of this framework. (and it's bad practice to being with) Not cool guys, not cool. |
I am keen to adopt bootstrap but this kind of thing is the reason why I've avoided it for so long. despite what this albeit brilliantly put article may say http://j.mp/1sESpoT , using !important is as all above suggested:
I've made my own work-around for now and will continue to work with Bootstrap, but I will proceed with a great deal of caution and very wary as to what else and how many more of these quirks I will find. |
Since .hide was deprecated in favor of .hidden, I wonder if its time to allow .hide to be set to not !important - especially since you can't easily override .hide { } with the !important in it - people that need to put the reverse compatability back in could easily go back in and add a custom less file into their bootstrap.less at the end, - right now I'm forced to edit the utilities.less directly. |
@er1c That's not how SemVer-compliant backward-compatibility works. We can't make those sorts of changes until v4. |
@cvrebert This sort of thing is making the task of moving something from Bootstrap v2 to v3 VERY difficult. There is no need for it on .hide, .pull-left, .pull-right, etc. I can understand it being approached in things such as media queries for printing, but it serves no purpose on global things such as .hide. Correct me if I'm wrong on this, but is it essentially the scenario of "fix something that's breaking a large amount of everything else, or just leave it in favor of being compliant with versioning"? To be honest it's very worrying if this usage of "!important" could possibly remain in Bootstrap until v4. |
@ryanmcnz Dude, I think we're in the same boat :) Just suggesting a possible short-term fix that doesn't require me to have my own custom bootstrap distribution. |
@er1c @dmlyapin
|
I think that this doesn't need to be fixed. |
@DaSchTour After all that's where the change is most noticed. It's a terrible thing to debug when something is being overridden with !important. |
This is exactly the case I found myself in...migrating from v2.3.2 to 3.1.1 and all of my existing jquery code (which bootstrap does depend on - so it's not like it's a random library "non standard" library) was suddenly broken. The good news for me was .hide did get deprecated in 3.0.1 - so glad I procrastinated my upgrading to bootstrap3 :) I hate having to edit the utilities.less file directly, but it ends up being a great solution to just remove the !important from the .hide style. Everything else that uses the official bootstrap3 .hidden still operates fine. |
@ryanmcnz @er1c And the problem with a large volume of code in multiple files can me easily solved with a good IDE with search replace over multiple files. Did it myself with Eclipse and it worked great. When using jQuery, CSS and Bootstrap V2 and V3 correctly than this is not an issue! |
@DaSchTour To keep on topic, If this isn't an issue with Bootstrap, then please explain to me why ".hide" needs !important on it, and why usage of !important on a global class is suddenly not a bad practice anymore. The point I'm trying to get across here is still this: |
@ryanmcnz To the point why .hide should have !important: For example to have the possibility to hide an element by adding the class hide through jQuery for an element, that has a class with display:block that might override this. It takes care of the fact, that the class really get's applied. |
+1 for removing |
I can't believe that bootstrap uses an !important flag on the hidden class. That prevents styles from overriding the hidden, and breaks jQuery.show(). Really disappointed in this and think it's poor CSS practice. Please remove the !important flag from these attributes. |
X-Ref: #9881 |
I think a version of .hide and .show without !important rule might be useful.
In my case they create problems on working with jQuery show() and hide() functions.
The text was updated successfully, but these errors were encountered: