修复了引导程序内容

时间:2018-05-19 16:58:18

标签: html css bootstrap-4 frontend

使用bootstrap处理响应式模板并尝试创建类似的东西 enter image description here

我知道,bg可以是FirstCap <- function(x) { for(i in seq_along(x)){ if(!is.na(x[i])){ x[i] = paste0(toupper(substring(x[i], 1, 1)), substring(x[i], 2), sep = "") } } x } vector <- c( "DSL" , "Fiber optic" , "No", NA, "fiber optic") FirstCap(vector) #[1] "DSL" "Fiber optic" "No" NA "Fiber optic" #Some more usages of the function FirstCap FirstCap(c("hello world", "i m hero", "its interesting to work in r")) #[1] "Hello world" "I m hero" "Its interesting to work in r" ,但内容是.container-fluid对齐的。如何才能做到这一点?现在我有了这个结构

container

现在文本被拉伸到容器的整个宽度。我需要嵌套容器,例如

<div class="services">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12 col-md-4 services-black">
                <h1>SEO Optimized</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
                </p>
            </div>
            <div class="col-12 col-md-4 services-red">
                <h1>Responsive</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
                </p>
            </div>
            <div class="col-12 col-md-4 services-green">
                <h1>Cloud Services</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
                </p>
            </div>
        </div>
    </div>
</div>

还是其他什么?如何正确实现?

2 个答案:

答案 0 :(得分:1)

渐变方式

您可以指定background:linear-gradient(to right,black,black,green,green)以获得所需的背景。 并container作为您内容的课程。

.services {
  background: linear-gradient(to right, black, black, green, green);
}

.services-red {
  background: red;
  color: white;
}

.services-green {
  background: green;
  color: white;
}

.services-black {
  background: black;
  color: white;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="services">
  <div class="container">
    <div class="row">
      <div class="col-12 col-md-4 services-black">
        <h1>SEO Optimized</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
        </p>
      </div>
      <div class="col-12 col-md-4 services-red">
        <h1>Responsive</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
        </p>
      </div>
      <div class="col-12 col-md-4 services-green">
        <h1>Cloud Services</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
        </p>
      </div>
    </div>
  </div>
</div>

Bootstrap + Flex Way

如何实现您期望的空间:

  1. <div>
  2. 中添加另一个services-*
  3. 根据您的方便给它一个宽度。
  4. 在您的容器上,services-*提供以下属性

    .services-black{
      display:flex;
      justify-content:flex-end; // Align box to right
    }
    .services-green{
      display:flex;
      justify-content:flex-start;  //Align box to left
    }
    .services-red{
      display:flex;
      justify-content:center;    //Align box to center
    }
    
  5. .cloud,
    .seo,
    .responsive {
      width: 60%;
    }
    
    .services-black {
      background: black;
      color: white;
      display: flex;
      justify-content: flex-end;
    }
    
    .services-green {
      background: green;
      color: white;
      display: flex;
      justify-content: flex-start;
    }
    
    .services-red {
      background: red;
      color: white;
      display: flex;
      justify-content: center;
    }
    
    @media (max-width: 768px) {
      .cloud,
      .seo,
      .responsive {
        width: 100%;
      }
    }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
    <div class="services">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12 col-md-4 services-black">
            <div class="seo">
              <h4>SEO Optimized</h4>
              <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
              </p>
            </div>
          </div>
          <div class="col-12 col-md-4 services-red">
            <div class="responsive">
              <h4>Responsive</h4>
              <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
              </p>
            </div>
    
          </div>
          <div class="col-12 col-md-4 services-green">
            <div class="cloud">
              <h4>Cloud Services</h4>
              <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
              </p>
            </div>
    
          </div>
        </div>
      </div>
    </div>

答案 1 :(得分:0)

您可以在.container之后嵌套.container-fluid,也可以在课程.services.container-fluid上加密background-color并将背景颜色设为例如,我为.services clas使用了伪元素

.services:before {
  position: absolute;
  left: 0;
  top: 0;
  background-color: black;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

.services:after {
  position: absolute;
  right: 0;
  top: 0;
  background-color: green;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

&#13;
&#13;
 /* you can also give the styles to the .container-fluid*/
.services {
  position: relative;
  color: white;
}

.services:before {
  position: absolute;
  left: 0;
  top: 0;
  background-color: black;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}

.services:after {
  position: absolute;
  right: 0;
  top: 0;
  background-color: green;
  height: 100%;
  width: 33.333%;
  display: block;
  content: "";
  z-index: -1;
}


.services-black {
  background-color: black;
}

.services-red {
  background-color: red;
}

.services-green{
  background-color: green;
}
&#13;
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
        <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
        
         <div class="services">
<div class="container-fluid">
<div class="container">
<div class="row">
<div class="col-12 col-md-4 services-black">
<h1>SEO Optimized</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
</p>
</div>
<div class="col-12 col-md-4 services-red">
<h1>Responsive</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
</p>
</div>
<div class="col-12 col-md-4 services-green">
<h1>Cloud Services</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
</p>
</div>
</div>
</div>
</div>
</div>
&#13;
&#13;
&#13;