简体   繁体   English

缩小 col-md-6 的左右边框

[英]Shrink the left and right borders of a col-md-6

I've got two col-md-6 items inside a row container, but I'm not able to shrink the left and right borders while keeping the text centered.我在一个行容器中有两个 col-md-6 项目,但是我无法在保持文本居中的同时缩小左右边框。 Here is my html:这是我的 html:

<div class="row">
 <div class="col-xs-6">
      <div class="card">
          <h4>How can mirrors be real if our eyes aren't real?</h4>
          <p>How can mirrors be real if our eyes aren't real?</p>
       </div>
  </div>
  <div class="col-xs-6">
     <div class="card">
       <h4>How can mirrors be real if our eyes aren't real?</h4>
       <p>How can mirrors be real if our eyes aren't real?</p>
      </div>
  </div>
</div>

and the css:和CSS:

.col-xs-6 {
    border-radius: 6px;
    border: 2px solid blue;
    padding-bottom: 10px;
    padding-top: 10px;
    padding-right: 15px;
    padding-left: 15px;
    margin-bottom: 20px;
    background: red;
    position: relative;
}

.row {
    margin-left: -15px;
    margin-right: -15px;
}

You can see that I've tried adjusting the margins, the padding, even making the columns xs, and nothing works.您可以看到我尝试调整边距、填充,甚至将列设为 xs,但没有任何效果。 Is it just not possible, are they not dynamic like I'm trying to make them?这是不可能的,它们不是像我试图制作它们那样动态吗? Thanks.谢谢。

try this code试试这个代码

<div class="row">
 <div class="col-xs-6">
      <div class="card">
          <h4>How can mirrors be real if our eyes aren't real?</h4>
          <p>How can mirrors be real if our eyes aren't real?</p>
       </div>
  </div>
  <div class="col-xs-6">
     <div class="card">
       <h4>How can mirrors be real if our eyes aren't real?</h4>
       <p>How can mirrors be real if our eyes aren't real?</p>
      </div>
  </div>
</div>
and the css:

.col-xs-6 {
    border-radius: 6px;
    border-left: 2px solid blue;
   border-right: 2px solid blue;
    padding-bottom: 10px;
    padding-top: 10px;
    padding-right: 15px;
    padding-left: 15px;
    margin-bottom: 20px;
    background: red;
    position: relative;
}

.row {
    margin-left: -15px;
    margin-right: -15px;
}

 .col-xs-6 { border-radius: 6px; border: 2px solid blue; border-top:none; border-bottom:none; padding-bottom: 10px; padding-top: 10px; padding-right: 15px; padding-left: 15px; margin-bottom: 20px; background: red; position: relative; } .row { margin-left: -15px; margin-right: -15px; width:90%; margin:0 auto; }
 <div class="row"> <div class="col-xs-6"> <div class="card"> <h4>How can mirrors be real if our eyes aren't real?</h4> <p>How can mirrors be real if our eyes aren't real?</p> </div> </div> <div class="col-xs-6"> <div class="card"> <h4>How can mirrors be real if our eyes aren't real?</h4> <p>How can mirrors be real if our eyes aren't real?</p> </div> </div> </div>

is this the same that you want ?这和你想要的一样吗?

here is JSFiddle这是JSFiddle

Realized I could wrap a col-xs-12 element in a col-xs-6 element and it would give me the spacing I wanted.意识到我可以将col-xs-12元素包装在col-xs-6元素中,它会给我我想要的间距。

Instead of而不是

<div class="col-xs-6">
        ....
</div>

I just did我刚做了

<div class="col-xs-6">
    <div class="col-xs-12>
            ...
    </div>
</div>

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

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