How many CSS selectors can be included?
P粉002572690
P粉002572690 2023-08-16 11:30:40
0
1
508
<p>I've tried looking for an answer to this problem, but to no avail: </p> <p>I am using css selector to locate all class names starting with col-1, col-2, col-3, col-[class*="col-"]. But I'm running into conflicts with some other third-party integration class names: <code>col-md-11</code>, <code>col-lg-2</code>, <code>col-sm- 3</code>... Thanks a lot, does anyone have any ideas to select only the class names: col-1, col-2, col-3, col-... The most concise way (maybe just one line of code ). </p> <p>My HTML example: </p> <pre class="brush:php;toolbar:false;"><div class="row row_1"> <div class="col-4"></div> <div class="col-10"></div> <div class="col-3"></div> <div class="col-md-11"></div> </div> <div class="row row_2"> <div class="col-12"></div> <div class="col-lg-2"></div> <div class="col-8"></div> <div class="col-sm-3"></div> </div></pre> <p>I tried searching on the internet but couldn't find a solution. </p>
P粉002572690
P粉002572690

reply all(1)
P粉416996828

It's a bit complicated, but you can combine your existing content with a :not selector;

[class*='col-']:not([class*='col-md'],[class*='col-lg'],[class*='col-sm']){
  color: red;
}
<div class="row row_1">
  <div class="col-4">红色</div>
  <div class="col-10">红色</div>
  <div class="col-3">红色</div>
  <div class="col-md-11">非红色</div>
</div>
<div class="row row_2">
  <div class="col-12">红色</div>
  <div class="col-lg-2">非红色</div>
  <div class="col-8">红色</div>
  <div class="col-sm-3">非红色</div>
</div>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template