废话少说,先上代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>Bootstrap Grid System</title>
<!-- Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-2" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=FF7F50&outline=yes" alt=""/>
</div>
<div class="col-md-2" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=FF7F50&outline=yes" alt=""/>
</div>
<div class="col-md-2" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=FF7F50&outline=yes" alt=""/>
</div>
<div class="col-md-2" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=FF7F50&outline=yes" alt=""/>
</div>
<div class="col-md-2" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=FF7F50&outline=yes" alt=""/>
</div>
</div>
<div class="row">
<div class="col-sm-3" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=00FFFF&outline=yes" alt=""/>
</div>
<div class="col-sm-3" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=00FFFF&outline=yes" alt=""/>
</div>
<div class="col-sm-3" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=00FFFF&outline=yes" alt=""/>
</div>
<div class="col-sm-3" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=00FFFF&outline=yes" alt=""/>
</div>
<div class="col-sm-3" style="width:20%">
<img data-src="holder.js/234x200?text=234x200&bg=00FFFF&outline=yes" alt=""/>
</div>
</div>
<div class="row">
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=2a2025&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=2a2025&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=2a2025&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=2a2025&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=2a2025&outline=yes" alt=""></div>
</div>
<div class="row">
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=7FFF00&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=7FFF00&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=7FFF00&outline=yes" alt=""></div>
<div class="col-sm-3"><img data-src="holder.js/292x200?text=292x200&bg=7FFF00&outline=yes" alt=""></div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.js"></script>
<script src="https://cdn.bootcss.com/holder/2.9.4/holder.js"></script>
</body>
</html>
自己新建一个html文档,然后在浏览器中打开效果如下所示:
所以如果你要定义成5列的话只需要bootstrap的列的样式,然后重新定义列宽就好了,不要修改bootstrap本身的列宽,那样会影响你其他页面使用的。