如何在引导程序3/4中将4个矩形框置于屏幕中心?

时间:2017-08-28 17:49:46

标签: html css twitter-bootstrap bootstrap-4

我在CSS中制作了4个矩形框。这是fiddle

此时,它们看起来与以下设计完全相似。我想知道,我如何在Bootstrap 4中完全相同(下面)设计(我在小提琴中制作)

enter image description here

我用于框的CSS是:

/***** Company heads CTO, CFO, and CEO START ************/

.company-heads {
    margin-left: 300px;
    padding-top: 80px;
    font-style: italic;
    margin-right: 289px
}

.company-heads .rectangle {
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 30px;
    margin-right: 22px;
    width: 355px;
    height: 100px;
    border: 1px solid #000;
    background-color: white;
    padding: 10px 10px 10px 100px;
    position: relative;
}

.company-heads .rectangle .circle {
    background: #aaa;
    border-radius: 100%;
    height: 60px;
    width: 60px;
    position: absolute;
    top: 20px;
    left: 20px;
}


/***** Company heads CTO, CFO, and CEO FINISH ************/

矩形框的宽度目前为355像素,但可以根据屏幕大小进行调整。

我尝试在Bootstrap 4中使用以下代码,但它没有成功。

<div class="container">
   <div class="row justify-content-center">
      <div class="col-lg-3 left-side">ABC</div>
      <div class="col-lg-3 right-side">DEF</div>
  </div
</div>

1 个答案:

答案 0 :(得分:0)

.row {
  text-align:center;
}

.col-md-4 {
  border-radius:20px;
  margin:10px;
  border:1px solid #000;
  display:inline-block;
  float:none !important;
}

.col-md-2 {
  border-radius:100%;
  height:60px;
  width:60px;
  background:#ccc;
  width:25%;
  margin:20px;
}

.row h1, .row p {
  font-style:italic;
  text-align:left;
}

.row h1 {
  font-size:1.4em;
}

.row p {
  font-size:1em;
}
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<div class="container">
  <div class="row">
    <div class="col-md-4">
      <div class="col-md-2"></div>
        <h1>Will's profile, CEO</h1>
        <p>Say something inspiring will</p>
    </div>
    <div class="col-md-4">
      <div class="col-md-2"></div>
        <h1>Will's profile, CEO</h1>
        <p>Say something inspiring will</p>
    </div>
  </div>
  <div class="row">
    <div class="col-md-4">
      <div class="col-md-2"></div>
        <h1>Zeeshan, CTO</h1>
        <p>Say something inspiring</p>
    </div>
    <div class="col-md-4">
      <div class="col-md-2"></div>
        <h1>Whoever yall hire next</h1>
        <p>Say something inspiring</p>
    </div>
  </div>
</div>

这是演示工作的代码。 New Demo

h1 {
  font-style: italic;
}

p {
  font-style: italic;
}

.col-md-5 {
  border-radius:15px;
  margin:10px;
  border:1px solid #000;
}

.col-md-2 {
  border-radius:100%;
  height:60px;
  width:60px;
  background:#ccc;
  width:25%;
  margin:20px;
}

.row h1 {
  font-size:1.4em;
}

.row p {
  font-size:1em;
}
<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<div class="container">
  <div class="row">
    <div class="col-md-5">
      <div class="col-md-2"></div>
        <h1>Will's profile, CEO</h1>
        <p>Say something inspiring will</p>
    </div>
    <div class="col-md-5">
      <div class="col-md-2"></div>
        <h1>Will's profile, CEO</h1>
        <p>Say something inspiring will</p>
    </div>
  </div>
  <div class="row">
    <div class="col-md-5">
      <div class="col-md-2"></div>
        <h1>Zeeshan, CTO</h1>
        <p>Say something inspiring</p>
    </div>
    <div class="col-md-5">
      <div class="col-md-2"></div>
        <h1>Whoever yall hire next</h1>
        <p>Say something inspiring</p>
    </div>
  </div>
</div>