Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Element type descendant selection works:
form * div {...}
but I find that using classes does not:
.my-class1 * .my-class2 {...}
I.e. I expect a few elements to be selected by the "class descendant" selection form, but none are.
In my page I have two very similar DOM sub-structures generated by third party code that needs different styling, and I don't want my CSS to relying on that third party DOM structure.
What is the best way to style these two parts of the DOM?
You can use .my-class1 > .my-class2 to direct descendants.
Or you can use .my-class1 .my-class2 for any .my-class2 that is descendant of .my-class1.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
So I saw online that using the :not() selector in CSS makes it so that whatever class you specified in the parenthesis will not apply those properties too. But that doesn't seem to be the case for me. For example,
.test .btn div:not(.classtoavoid){
...
...
...
}
So when I do what I showed above, it doesn't apply those properties to the .btn class where they don't have the div with class (classtoavoid). Am I using the :not selector incorrectly?
No
.test .btn div:not(.classtoavoid){
...
...
...
}
This does not select the .btn class, it selects any div which is a descendant of .btn which does not have the selected class.
You can't apply CSS to a parent based on a child (at least not yet).
You want :has() but that basically has almost (actually none) no support as yet.
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 1 year ago.
Improve this question
HTML
<a class="link cta"> link </a>
CSS
.link, .cta, .blueText, .title{
color: cyan;
}
The browser see the class names (link, cta) in html first then find the style in css and then apply the style.
Or
It see the class names (.link, .cta, .blueText, .title) in css first then find those class name in html and then apply the style.
I believe it's more like the second. Basically:
Not necessarily in this order:
The browser parses the HTML and creates a bunch of objects called The Document Object Model, or DOM.
The browser parses the CSS. Each CSS block is made up of a selector and then a bunch of properties.
For each CSS block, the browser looks through the DOM for all the elements that match the selector and then applies the properties.
In your above example, the selector is a list of classes but there are other kinds of selectors.
Note that in real life things don't always work out in that simple order as things can be loaded late, etc.
Hopefully that is of some help...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
This is the page I am working with: https://books.fcostry.cz/
What I am trying to do is hide the searchbox (.vc-searchbox) on hover of the Books logo on the left upper side (.vc-headerlogo).
.vc-headerlogo:hover .vc-searchbox{ display:none; } is not working and I really don't know why.
I would like to do it using CSS but I am open to any solution. Thanks for any answer.
.vc-headerlogo:hover .vc-searchbox{display:none;}
Means that .vc-searchbox nested in .vc-headerlogo will not be displayed when overing .vc-headerlogo
In your page, this is not the case: .vc-searchbox is not in .vc-headerlogo, but after (they are sibling). In that case, use the CSS sibling selector +
In other words,
.vc-headerlogo:hover+.vc-searchbox{display:none;}
should work better
Since you are open to options, use jQuery
$(document).ready(function(){
$('.vc-headerlogo').hover(function(){
$('.vc-searchbox').hide();
});
});
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I want to target the class has-translucent-status-bar which is located inside another class named platform-ios
For that I've tried to do:
.platform-ios > .has-translucent-status-bar
So far, I was not lucky enough to do so, here is a screenshot of the code:
You should go with:
.platform-ios .has-translucent-status-bar
The child selector/combinator you used is for direct children:
The > combinator separates two selectors and matches only those
elements matched by the second selector that are direct children of
elements matched by the first.
In your specific case, the only, or one among the others, direct child of .platform-ios is ion-app element.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have HTML like this:
<div class="myList">
<select>
<option value="1">Item1</option>
<option value="2">Item2</option>
</select>
</div>
All the CSS is perfect. But then, when I use some AJAX, and then I do $('.myList').html(...), all the styling of the combobox disappears.
I tried some of the ideas in other threads, but none of them worked.
When you are call ($element).html you overwrite the HTML what is currently there, therefore you may actually be overwriting the HTML which sets the div (and therefore styling) use $(element).append instead, here is the API for .append() http://api.jquery.com/append/
Probably because you add your styles with jquery, so you add your styles in the html as an attribute with style="", you can add your styles in the css and with jquery just add the classes. And when you change the html add the classes again otherwise you'll miss the styling.