简体   繁体   English

删除3个HTML列之间的空格

[英]Removing space between 3 HTML columns

In the code below I have 3 col-md-4 that I want to reduce the space between to about 25px. 在下面的代码中,我有3 col-md-4 ,我想将其之间的空间减小到大约25px。 I've tried reducing the margin between them along with increasing the padding on the left and right side of the first and last column respectively. 我尝试减少它们之间的边距,并分别增加第一列和最后一列的左侧和右侧的填充。 The problem with this approach is that when the window size is manipulated it makes the image columns offset because of the increased padding. 这种方法的问题在于,当操纵窗口大小时,由于填充增加,会使图像列偏移。

HTML: HTML:

<div class="cards">
  <div class="container">
    <h2>
      Our Expertise.
    </h2>
  </div>
  <div class="row">
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
    <div class="col-md-4">
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
     <!-- <img> -->
    </div>
  </div>
</div>

CSS: CSS:

 html, body {
 margin: 0;
 padding: 0;
 font-family: 'Libre Baskerville', sans-serif;
 }

  .first    {
     padding-left: 200px !important;
  }

  .last {
    padding-right: 200px !important;
  }

  .container {
    max-width: 980px;
    margin: 0 auto;
  }

  .header   {
    padding-top: 20px;
  }

  .header h1    {
    font-size: 20px;
  }

  .nav li   {
    margin: 0px;
    border: 0px;
  }
  .nav li a {
    color: #333;
  }

  .jumbotron {
     background-color: transparent;
     padding-top: 100px;
     padding-bottom: 100px;

  }
  .jumbotron h2     {
     font-size: 50px;
  }
  .jumbotron h2 span    {
     color: #ffc200;
  }

  .banner {
     background-color: #333;
     height: 140px;
     color: white;
     text-align: center;
     padding-top: 30px;
  }

  .cards {
     background-color: #FFC200;
     text-align: center;
  }

  .cards img {
     margin-bottom: 25px;
     padding: auto;
  }

  .cards h2 {
     margin-top: 20px;
     margin-bottom: 80px; 
  }

  @media (max-width: 992px) {
     .col-md-4 {
     margin: 0 auto 0;
     text-align: center;
     width: 100%;
  }

  .cards img {
    width: 60%;
   } 
  }

@media (max-width: 500px) {
  .header h1 {
    text-align: center;
}

  .nav li {
    text-align: center;
    width: 100%;
}

  .cards img {
    width: 100%;
   }
 }

There are suppose to be images in the columns but because I don't have 10 rep points it wont let me post them. 列中应该有图像,但是由于我没有10个代表点,因此我无法发布它们。

Just change the default column padding. 只需更改默认的列填充。 You need to keep the total space between the columns an even number, so 24 would be good, you would simply change the default column padding from 15px to 12px and override the negative margin on the row as well: 您需要将列之间的总间隔保持为偶数,所以24会很好,您只需将默认列填充从15px更改为12px并覆盖行上的负边距即可:

 .row { margin-left: -12px!important; margin-right: -12px!important; } div[class*='col-'] { padding-left: 12px; padding-right: 12px; } .inner { border:1px solid black; } 
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> <div class="cards"> <div class="container"> <h2> Our Expertise. </h2> </div> <div class="row"> <div class="col-md-4"> <div class="inner">Column 1</div> </div> <div class="col-md-4"> <div class="inner">Column 2</div> </div> <div class="col-md-4"> <div class="inner">Column 3</div> </div> </div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM