How to do element selection inside another element?
P粉590929392
P粉590929392 2023-08-22 11:08:56
0
2
465
<p>I have a question about CSS selectors. When a <code><div></code> with a specific class name is inside a <code><ul></code> with a class name <code>saft</code> How should I choose it? This CSS class is used elsewhere and I don't want to change the style everywhere. </p> <pre class="brush:php;toolbar:false;"><div id="floater"> <ul class="saft"> <li><div class="textSlide"></li> </ul> </div></pre>
P粉590929392
P粉590929392

reply all(2)
P粉463811100

Just execute:

ul.saft .textSlide {

This will achieve the functionality you require

P粉549412038

Just use the CSS descendant selector (one space) between the parent element and the child element:

ul.saft div.textSlide {
    /* CSS规则 */
}

* {
  margin: 0;
  padding: 0
}

li {
  list-style-type: none;
}

ul.saft div.textSlide {
  background-color: #f90;
  font-weight: #000;
}
<ul class="saft">
  <li>
    <div class="textSlide">在textSlide类元素中的一些文本</div>
  </li>
</ul>
<div class="textSlide">更多文本,也在textSlide元素中</div>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!