jquery - 嵌套的 div 和移动列

标签 jquery html css twitter-bootstrap

我目前正在处理一行,上面有文本,下面有 4 个图标作为列出的 div。我让它们在桌面上跨越 100% 的 div,在平板电脑上跨越 2 个,但我无法让它们在移动设备上堆叠 2 个。我只让它们一层一层地堆叠起来。关于如何让他们显示 2 的任何想法?我使用媒体查询来缩小字体,但我不知何故被卡住了。

我尝试将类 col-xs-6 添加到 div,但这似乎不起作用。我对 bootstrap 还很陌生,所以我可能不太了解它是网格系统。

抱歉,我是一个正在努力学习的新手,我查看了其他网站的源代码但找不到解决方案。

Desktop:
[[ MAIN DIV W/ TEXT ]]
[[1]] [[2]] [[3]] [[4]]

Tablet:
[[ MAIN DIV ]]
[[1]] [[2]]
[[3]] [[4]]
Mobile:
[[ MAIN DIV ]]
[[1]]
[[2]]
[[3]]
[[4]]

这是我的一小段代码:https://jsfiddle.net/hecq0yq6/1/

@import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );

.discuss {
  background-color: #00CCDD;
  padding-bottom: 50px;
}

.discuss h1 {
  text-transform: uppercase;
  font-family: Impact, sans-serif;
  font-size: 55px;
  padding-top: 40px;
  padding-bottom: 40px;
  color: #FFF;
  margin: 0;
}

.discuss p {
  color: #FFF;
  font-size: 17px;
  padding: 0 50px 0 50px;
  width: 100%;
  text-align: center;
}

.icons {
  margin-top: 20px;
  /*	margin-bottom: 40px;*/
  text-align: center;
  color: #FFF;
}

.icons a:hover {
  text-decoration: none;
  color: #FFF;
}

@media (max-width: 767px) {
  .icons,
  h3 {
    font-size: 12px;
  }
}
<!-- DISCUSS SECTION NESTED WITH ICONS -->
<div class="row col-xs-12 discuss">
  <h1 class="text-center">HEADER</h1>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum</p>
  <p>Not sure why you use lorem ipsum?</p>

  <!-- NESTED 4 COLUMNS TEST -->

  <div class="row">

    <!-- Div col-sm-3 -->
    <div class="col-sm-6 col-lg-3 icons"> <a href="http://www.google.com" class="icons"><i class="fa fa-user" style="font-size:48px;"></i><br>
              <h3>Icon<br>
              #1</h3>
              </a> </div>
    <div class="col-sm-6 col-lg-3 icons"> <a href="http://www.yahoo.com" class="icons"><i class="fa fa-users" style="font-size:48px;"></i><br>
              <h3>Icon<br>
              #2</h3>
              </a> </div>
    <div class="col-sm-6 col-lg-3 icons"> <a href="http://www.dicks.com" class="icons"><i class="fa fa-briefcase" style="font-size:48px;"></i><br>
              <h3>Icon<br>
              #3</h3>
              </a> </div>
    <div class="col-sm-6 col-lg-3 icons"> <a href="http://www.cnn.com" class="icons"><i class="fa fa-file-text" style="font-size:48px;"></i><br>
              <h3>Icon<br>
              #4</h3>
              </a> </div>
  </div>
</div>

最佳答案

使用 .col-xs-6 作为 .col-md-6 的补充或替代。

@import url( 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );

.discuss {
  background-color: #00CCDD;
  padding-bottom: 50px;
}

.discuss h1 {
  text-transform: uppercase;
  font-family: Impact, sans-serif;
  font-size: 55px;
  padding-top: 40px;
  padding-bottom: 40px;
  color: #FFF;
  margin: 0;
}

.discuss p {
  color: #FFF;
  font-size: 17px;
  padding: 0 50px 0 50px;
  width: 100%;
  text-align: center;
}

.icons {
  margin-top: 20px;
  /*	margin-bottom: 40px;*/
  text-align: center;
  color: #FFF;
}

.icons a:hover {
  text-decoration: none;
  color: #FFF;
}

@media (max-width: 767px) {
  .icons,
  h3 {
    font-size: 12px;
  }
}
<!-- DISCUSS SECTION NESTED WITH ICONS -->
<div class="row">
  <div class="col-xs-12 discuss">

    <h1 class="text-center">HEADER</h1>
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
    </p>
    <p>
      Not sure why you use lorem ipsum?
    </p>

    <div class="row">

      <div class="col-xs-6 col-sm-6 col-lg-3 icons">
        <a href="http://www.google.com" class="icons">
          <i class="fa fa-user" style="font-size:48px;"></i>
          <br>
          <h3>Icon<br> #1</h3>
        </a>
      </div>
      <div class="col-xs-6 col-sm-6 col-lg-3 icons">
        <a href="http://www.yahoo.com" class="icons">
          <i class="fa fa-users" style="font-size:48px;"></i>
          <br>
          <h3>Icon<br> #2</h3>
        </a>
      </div>
      <div class="col-xs-6 col-sm-6 col-lg-3 icons">
        <a href="http://www.dicks.com" class="icons">
          <i class="fa fa-briefcase" style="font-size:48px;"></i>
          <br>
          <h3>Icon<br> #3</h3>
        </a>
      </div>
      <div class="col-xs-6 col-sm-6 col-lg-3 icons">
        <a href="http://www.cnn.com" class="icons">
          <i class="fa fa-file-text" style="font-size:48px;"></i>
          <br>
          <h3>Icon<br> #4</h3>
        </a>
      </div>
    
    </div>
  </div>
</div>

FWIW .row 应该用在单独的元素上,而不是用在像 .col-xs-12 这样的列类的元素上。

关于jquery - 嵌套的 div 和移动列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44291169/

相关文章:

html - 在 Spring 3 中使用框架集

html - 用纯html和css画带框的棋盘

html - 尽管使用了溢出标签,但无法让 div 在页面内滚动

jquery - 固定标题对齐问题

php - 将值从 php 传递到 jquery

jquery - jQuery 中的输入框动画留下 "trail",有什么办法摆脱它吗?

javascript - 在本地 xampp 服务器中发送邮件时出错

php - 在单个浏览器中检查不同的浏览器兼容性

javascript - 如何使用 jQuery 更改可折叠内容的标题属性

jquery - 如何突出显示 jquery 移动面板中的选定链接?