Why would this Boostrap selector be used? [closed] - css

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I was going through the main boostrap.css file and came across several uses of this selector:
.btn-group-vertical > .btn:first-child:not(:last-child) {}
So it's selecting an element that has the .btn class which is a first child (but also not a last child?) of an element with the class .btn-group-vertical
Why would there be a need for the chained :not() selector? I can't imagine a use case for this.

The use case would be if it's a single element in the group, wherein it's both the first and last child.

I opened an issue on Github and got a response from the creator himself (Mark Otto):
:first-child and :last-child can apply to the same element if it's the
only child element. We do this to avoid overriding properties again
and again. If we did :only-child we'd have to write another selector
altogether.

Related

Advanced css form selectors [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 months ago.
Improve this question
Hello guys I have this CSS selector and I can't figure out how to read it. Can someone explain? Thanks
.form__input:not(:placeholder-shown).form__input:not(:focus)+.form__label {
The ideal is that in nested css classes you put them one below the other for easy reading, since it can contain many elements and about your question
.form__input:not(:placeholder-shown)
// apply the class to all .form__input that do not have the selector "placeholder-shown".
.form__input:not(:focus) // applies the css to all .form__input not in "focus".
+.form__label // here applies the css to the input label
{

Is this a valid CSS Selector? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
With-respect to the following expression:
radio:focus > .approve, radio:focus > .dis-approve{/*statements...*/}
Is it accepted by CSS interpreter/compiler?
Objective: applies iff both .approve and .dis-approves' radio-typed parents are in-focus.
It is valid (see BoltClock's comment), but you'll find that it will not match anything as it has several problems:
radio isn't a valid HTML element. Did you mean input[type=radio]?
If you did mean input[type=radio], that element cannot have children, so > .approve and > .dis-approve wouldn't select anything. Did you mean + .approve and + .dis-approve, to an element next to this one?
The best way to know if your CSS works is to apply your CSS to a HTML structure which should accompany this and see what happens.

CSS: One class VS selecting many elements [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
For a responsive website is there a best practice to hide/show elements altogether in a media selector? E.g. is it better to have a class called .hide_on_desktop (which sets display: none;) and then to add that class to several elements in the website using HTML.
Or to do the following:
.element1, .element2, #element3{
display: none;
}
In the above case element1, element2 and element3 are selectors (classes and ids) that already exist.
Which approach is best for a big website?
I would suggest creating a hidden class if you plan to hide several objects. Bootstrap handles this by having classes: .hidden-xs, .hidden-sm, .hidden-md,etc.. in order to hide elements based on device width.
http://getbootstrap.com/css/#responsive-utilities

CSS selector notation [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
maybe a silly question but as far as I like standards I'd like to know, how should we write CSS selectors:
.my-selector-for-div (breaks)
.mySelectorForDiv (camel case)
Is there a standard which of those ( or any other ) should be used ?
Here is a website of css name convention (with examples):
http://www.realdealmarketing.net/docs/css-coding-style.php
There are some interesting articles about code formating (about CSS and BEM methodology):
http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/
http://coding.smashingmagazine.com/2012/04/16/a-new-front-end-methodology-bem/
I'd go with matching the language. In CSS' case it uses hyphenation regularly so for selectors I would also use hyphens even though I personally find them ugly.
Not sure if there's a proper style guide for them though.
edit: Can I use camel-case in CSS class names seems to also say use hyphens for class names.

Advantages and disadvantages of using ID selectors in CSS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This post talked about the disadvantage about using ID selectors in CSS. Do you more about the advantages and disadvantages about using ID selectors in CSS? When should I use ID selectors and when should I use class selectors? Thanks.
The id selector is used to specify a style for a single, unique element.
The id selector uses the id attribute of the HTML element, and is defined with a "#".
The style rule below will be applied to the element with id="para1":
#para1
{
text-align:center;
color:red;
}
Reference : Ref
It simply identifies one instance for an ID, a class will be inherit in the overall website, higher lvls of importance.
IDs have a higher level of specificity than classes in CSS. This helps to create strong reference points for children selectors. They're faster and easier to identify in the DOM versus a class.
Although, this really means nothing! ID's and classes are more abstract concepts than anything. General rule:
Multiple Elements - Class
Element Singleton - ID
Does it really matter? Not really.

Resources