html – 动态中心div bootstrap

html – 动态中心div bootstrap,第1张

概述我正在尝试创建一个响应式div列表 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.mi 我正在尝试创建一个响应式div列表

<script src="https://AJAX.GoogleAPIs.com/AJAX/libs/jquery/2.1.1/jquery.min.Js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap.min.CSS" integrity="sha384-BVYIISIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap-theme.min.CSS" integrity="sha384-rHyoN1irsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/Js/bootstrap.min.Js" integrity="sha384-Tc5IQib027qvyJsMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><div >  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div></div>

正如你所看到的,从上面我有四个div,当我只有3个div时,它们会在左边

当只有3个div并且它们将居中时,它是否可以动态地进行?

如果是的话,我该怎么办呢.提前谢谢,抱歉我的英语不好

解决方法 要进行测试,请尝试删除列.

对于所有决议:

<script src="https://AJAX.GoogleAPIs.com/AJAX/libs/jquery/2.1.1/jquery.min.Js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap.min.CSS" integrity="sha384-BVYIISIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap-theme.min.CSS" integrity="sha384-rHyoN1irsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/Js/bootstrap.min.Js" integrity="sha384-Tc5IQib027qvyJsMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><div >  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div></div><style> .col-xs-6:first-child:nth-last-child(3),.col-xs-6:first-child:nth-last-child(3) ~ .col-xs-6 {     wIDth: 33.3%; }</style>

仅限移动分辨率:

<script src="https://AJAX.GoogleAPIs.com/AJAX/libs/jquery/2.1.1/jquery.min.Js"></script><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap.min.CSS" integrity="sha384-BVYIISIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/CSS/bootstrap-theme.min.CSS" integrity="sha384-rHyoN1irsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/Js/bootstrap.min.Js" integrity="sha384-Tc5IQib027qvyJsMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script><div >  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div>  <div >    <a href="#">      <img src="https://dummyimage.com/250x250/000/fff">    </a>  </div></div><style>@media (max-wIDth:767px) {  .col-xs-6:first-child:nth-last-child(3),.col-xs-6:first-child:nth-last-child(3) ~ .col-xs-6 {      wIDth: 33.3%;  }}</style>

说明:

`.col-xs-6:first-child:nth-last-child(3)`

对于第一列的列,以及最后一列的第3列

,.col-xs-6:first-child:nth-last-child(3) ~ .col-xs-6

并且对于所述列的所有相邻兄弟姐妹(后面的每一列)

wIDth: 33.3%;

占宽度的1/3.

如果有4列或更多列,或者少于3列,则第一个孩子不能是最后一个,所以我们只在3时更改宽度.不需要flexBox(虽然我喜欢flexBox),不需要填充,没有bs.

总结

以上是内存溢出为你收集整理的html – 动态中心div bootstrap全部内容,希望文章能够帮你解决html – 动态中心div bootstrap所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1046654.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存