Bootstrap 3柱天沟

时间:2017-08-09 12:52:12

标签: html css twitter-bootstrap

我尝试多次修复此问题但仍然会发生,我无法找到正确的修复方法。 我不能在Bootstrap 3中的列周围创建阴沟。这里是我的小提琴:jsfiddle.net/creuxttL

我的确切问题:当我创建这三列时,我希望它们之间有一些排水沟,所以它们看起来不像一块大砖。默认情况下,我没有收到任何装订线,所以我尝试手动执行 - 使用css类.col。我仍然没有在盒子周围获得任何边距/填充物。我该怎么办?

3 个答案:

答案 0 :(得分:2)

你是小提琴没有包含bootstrap 3。 http://jsfiddle.net/va94exo2/稍作修改。

用内部div包装了所有col-md-4内容并将ID =“row”更改为类并删除了额外的.col类,然后还设置了内部div。

.inner-content{
  font-family: 'Roboto', sans-serif;
  font-weight: 100;
  color: white;
  text-align: center;
  background-color: #00b9ff;
  border: 1px solid black;
}
.overlay-pic {
  max-height: 200px;
  display: block;
  margin: auto;
}

.overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #44cbff;
  overflow: hidden;
  width: 100%;
  height: 0;
  transition: .5s ease;
}

.overlay p {
  font-family: 'Raleway';
  font-style: italic;
  white-space: nowrap;
  color: white;
  font-size: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
}

.col {
  /*gutter*/
  padding-right: 7px;
  padding-left: 7px;
}

.col:not(:first-child, :last-child) {
  padding-right: 7px;
  padding-left: 7px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row" style="margin-top: 10px;">
  
    <div class="col-md-4">
      <div class="inner-content">    
      
      <h1>Festival 2001</h1>
      <img src="event.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Our event.</p>
      </div>
      </div>
    </div>

    <div class="col-md-4">
    <div class="inner-content">
      <h1>Who are we?</h1>
      <img src="question.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Read more about us</p>
      </div>
      </div>
    </div>

    <div class="col-md-4">
    <div class="inner-content">
      <h1>where, when?</h1>
      <img src="calendar.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Look at our calendar.</p>
      </div>
    </div>
    </div>
    </div>
 
</div>

答案 1 :(得分:0)

不是肯定这是完全您正在寻找的内容但如果您只想在行之间留出空格,则可以在“.col-md”中为您的css添加“margin-top”属性-4“等级。

希望这有帮助。

.col-md-4 {
  font-family: 'Roboto', sans-serif;
  font-weight: 100;
  color: white;
  text-align: center;
  background-color: #00b9ff;
  border: 1px solid black;
  margin-top:10px;
}

.overlay-pic {
  max-height: 200px;
  display: block;
  margin: auto;
}

.overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #44cbff;
  overflow: hidden;
  width: 100%;
  height: 0;
  transition: .5s ease;
}

.overlay p {
  font-family: 'Raleway';
  font-style: italic;
  white-space: nowrap;
  color: white;
  font-size: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
}

.col {
  /*gutter*/
  padding-right: 7px;
  padding-left: 7px;
}

.col:not(:first-child, :last-child) {
  padding-right: 7px;
  padding-left: 7px;
}
<div class="container">
  <div id="row" style="margin-top: 10px;">
    <div class="col-md-4 col">
      <h1>Festival 2001</h1>
      <img src="event.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Our event.</p>
      </div>
    </div>

    <div class="col-md-4 col">
      <h1>Who are we?</h1>
      <img src="question.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Read more about us</p>
      </div>
    </div>

    <div class="col-md-4 col">
      <h1>where, when?</h1>
      <img src="calendar.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Look at our calendar.</p>
      </div>
    </div>
  </div>
</div>

答案 2 :(得分:0)

未添加Bootstrap。我修改了你的代码。我希望你期待这一点。

.col {
  font-family: 'Roboto', sans-serif;
  font-weight: 100;
  color: white;
  text-align: center;
  background-color: white;
}

.overlay-pic {
  max-height: 200px;
  display: block;
  margin: auto;
}

.overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #44cbff;
  overflow: hidden;
  width: 100%;
  height: 0;
  transition: .5s ease;
}

.overlay p {
  font-family: 'Raleway';
  font-style: italic;
  white-space: nowrap;
  color: white;
  font-size: 20px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
}

.col h1{
  margin-top:0px;
}
<div class="container">
  <div id="row">
    <div class="col-md-4 col">
    <div style="margin:5px; background:#00b9ff;border: 1px solid black;">
      <h1>Festival 2001</h1>
      <img src="event.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Our event.</p>
      </div>
      </div>
    </div>

    <div class="col-md-4 col">
    <div style="margin:5px; background:#00b9ff;border: 1px solid black;">
      <h1>Who are we?</h1>
      <img src="question.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Read more about us</p>
        </div></div>
    </div>

    <div class="col-md-4 col">
    <div style="margin:5px; background:#00b9ff;border: 1px solid black;">
      <h1>where, when?</h1>
      <img src="calendar.jpg" class="overlay-pic hidden-tablet img-responsive">
      <div class="overlay">
        <p>Look at our calendar.</p>
      </div>
      </div></div>
  </div>
</div>