0

How select only col-1,2,3......12 in css, I tried to use .row [class*='col-'] but it's select all grid classes.

.container .row [class*="col-*"] {
  background: red !important;
}
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta charset="utf-8" />
  <title>Hi Amma Bootstrap 4 </title>
  <link rel="stylesheet" type="text/css" href="bootstrap.css" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    .container .row [class*="col-*"] {
      background: red !important;
    }
  </style>
</head>

<body>
  <div class="container">
    <div class="row m-4">
      <div class="col-12 col-sm-6 col-md-3 bg-success">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
      </div>
      <div class="col-12 col-sm-6 col-md-3 bg-warning">
        Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
      </div>
      <div class="col-12 col-sm-6 col-md-3 bg-success mt-3">
        Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
      </div>
      <div class="col-12 col-sm-6 col-md-3 bg-warning mt-3">
        Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.

      </div>
    </div>
  </div>
</body>

</html>
m4n0
  • 29,823
  • 27
  • 76
  • 89
Anitha
  • 31
  • 6
  • Why you need this scenario, I mean if you want to target on mobile just use custom class rather then editing default framework classes – Awais Feb 12 '20 at 12:32
  • because I'm implementing bootstrap4 for admin dashboard, there are many pages & some pages are not accessable but need to target that pages as well, In order to target that i need this scenario. – Anitha Feb 12 '20 at 12:52
  • Does this answer your question? [How to style bootstrap col-lg-\* classes?](https://stackoverflow.com/questions/25229297/how-to-style-bootstrap-col-lg-classes) – Awais Feb 12 '20 at 13:12

1 Answers1

0
.col, [class*="col-"] {
// your style
    }
Mohcin Bounouara
  • 593
  • 4
  • 18
  • 2
    Hi and welcome to stackoverflow, and thank you for answering. While this code might answer the question, can you consider adding some explanation for what the problem was you solved, and how you solved it? This will help future readers to understand your answer better and learn from it. – Plutian Feb 12 '20 at 14:34