"No Gutter Grid with attribute selectors"
Bootstrap 3.2.0 Snippet by mrmccormack

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class='container'>
<h1>No Gutter Grid <small>with CSS attribute selectors</small></h1>
<p>Best viewed: <a href="http://bootsnipp.com/iframe/eNjV6" target="_blank">full screen</a>
</p>
<h3>Normal Grid</h3>
<div class='row'>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/1/' alt="">
</div>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/2/' alt="">
</div>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/3/' alt="">
</div>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/4/' alt="">
</div>
</div>
<h3>No Gutter Grid</h3>
<div class='row row-no-gutter'>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/1/' alt="">
</div>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/2/' alt="">
</div>
<div class='col-sm-3'>
<img class='img-responsive' src='//lorempixel.com/400/150/nature/3/' alt="">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
Ref: http://codepen.io/unavezfui/pen/Idyck/
Understanding [class*="col-"] - See line #26 below
Attribute selectors allow you to style an element’s box based
on the presence of an HTML attribute or of an attribute’s value
http://htmldog.com/guides/css/advanced/attributeselectors/
*/
body {
background-color: #222;
color: #ccc;
}
h3{
color:#f00;
}
.row-no-gutter {
margin-right: 0;
margin-left: 0;
}
.row-no-gutter [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: