繁体   English   中英

巨型机的元件未正确对齐

[英]Elements of the jumbotron is not properly aligned

美好的一天! 我正在努力使jumbtron对准我的日历图标。 并且jumbtron的元素不在其中。 有人可以帮我解决这个问题吗? 想法? 我刚刚开始学习引导程序和CSS。

这是图片。

在此处输入图片说明

这是我的html代码。

 <div class="events">
   <div class="container">
     <div class="row">
       <div class= "col-sm-4 col-xs-25">
         <h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
         <hr class="carved">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
         <div class="container">
           <div class="jumbotron">
             <h4>Sample Title</h4>
             <p>IT Thesis defense</p>
             <h6>7:00 AM - 8:00 PM</h6>
           </div>
         </div>
         <hr class="divider">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
         <hr class="divider">
         <div class="date">
           <span class="month">August</span>
           <h1 class="day">28</h1>
         </div>
       </div>
       <div class= "col-sm-8 col-xs-25">
         <h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
         <hr class="carved">
       </div>
     </div>
   </div>
 </div>

这是我的CSS

#event {
  color: #a92419;
}
hr.carved {
  clear: both;
  float: none;
  width: 100%;
  height: 2px;
  border: none;
  background: #ddd;
  background-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      color-stop(0.5, rgb(126,27,18)),
      color-stop(0.5, rgb(211,45,31))
  );
  background-image: -moz-linear-gradient(
      center top,
      rgb(126,27,18) 50%,
      rgb(211,45,31) 50%
  );
}
.date {
  display: block;
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  background: #fff;
  text-align: center;
  font-family: 'Helvetica', sans-serif;
  position: relative;
}
.date .month {
  background: #a92419;
  display: block;
  padding-bottom: 5px;
  padding-top: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  border-bottom: 2px solid #a92419;
  box-shadow: inset 0 -1px 0 0 #a92419;
}

.date .day {
  display: block;
  margin: 0;
  padding-bottom: 10px;
  padding-top: 5px;
  text-align: center;
  font-size: 20px;
  color:#a92419;
  box-shadow: 0 0 3px #ccc;
  position: relative;
}

.date .day::after {
  content: '';
  display: block;
  height: 95%;
  width: 96%;
  position: absolute;
  top: 3px;
  left: 2%;
  z-index: -1;
  box-shadow: 0 0 3px #ccc;
}

.date .day::before {
  content: '';
  display: block;
  height: 90%;
  width: 90%;
  position: absolute;
  top: 6px;
  left: 5%;
  z-index: -1;
}
.jumbotron {
  width: 300px;
  height: 100px;
  margin:none;
}
.jumbotron p {
  font-size:12px;
}
<div class="container">
    <div class="row">
         <div class="col-md-2">
         <h4 id="event"><i class="fa fa-calendar" aria-hidden="true"></i> Upcoming Events</h4>
         <hr class="carved">
        <div class="date">
        <span class="month">August</span>
        <h1 class="day">28</h1>
    </div><!-- date -->
</div><!-- md2 --> 

<div class="col-md-10">
<h4 id="event"><i class="fa fa-newspaper-o" aria-hidden="true"></i> Latest News</h4>
<hr class="carved">
    <div class="jumbotron">
    <h4>Sample Title</h4>
    <p>IT Thesis defense</p>
    <h6>7:00 AM - 8:00 PM</h6>
    </div><!-- jumbo -->
</div><!-- md10 -->

</div><!-row>
</div><!-- container -->

+

#event {
  color: #a92419;
}
hr.carved {
  clear: both;
  float: none;
  width: 100%;
  height: 2px;
  border: none;
  background: #ddd;
  background-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      color-stop(0.5, rgb(126,27,18)),
      color-stop(0.5, rgb(211,45,31))
  );
  background-image: -moz-linear-gradient(
      center top,
      rgb(126,27,18) 50%,
      rgb(211,45,31) 50%
  );
}
.date {
  display: block;
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  background: #fff;
  text-align: center;
  font-family: 'Helvetica', sans-serif;
  position: relative;
}
.date .month {
  background: #a92419;
  display: block;
  padding-bottom: 5px;
  padding-top: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  border-bottom: 2px solid #a92419;
  box-shadow: inset 0 -1px 0 0 #a92419;
}

.date .day {
  display: block;
  margin: 0;
  padding-bottom: 10px;
  padding-top: 5px;
  text-align: center;
  font-size: 20px;
  color:#a92419;
  box-shadow: 0 0 3px #ccc;
  position: relative;
}

.date .day::after {
  content: '';
  display: block;
  height: 95%;
  width: 96%;
  position: absolute;
  top: 3px;
  left: 2%;
  z-index: -1;
  box-shadow: 0 0 3px #ccc;
}

.date .day::before {
  content: '';
  display: block;
  height: 90%;
  width: 90%;
  position: absolute;
  top: 6px;
  left: 5%;
  z-index: -1;
}

结果

.container类具有自己的宽度,并且打算用作布局的外部包装。 因此,它们不太容易嵌套。 您作为.date分类元素的同级对象正在破坏布局。

至于.jumbotron内容的间距,Bootstrap默认为该类分配一些非常.jumbotron填充。 考虑在.jumbotron规则中使用您自己的值覆盖它。 另一个问题.jumbotron内容物从容器中渗出-这是height: 100px的结果height: 100px您正在设置height: 100px 您可以通过添加/修改其overflow属性来阻止内容占用.jumbotron边界之外的空间。 这可能是一个观点,但我认为通常最好避免在CSS中设置height ,而让内容定义容器的大小,尤其是在内容是由CMS /客户端驱动的情况下。

如果删除.container ,仍然会出现.date.jumbotron垂直堆叠的问题。 为了解决这个问题,您可以考虑将Date元素视为.row ,将.date元素的列和该Date事件的列。

<hr class="carved">

<div class=“row”><!-- the Date wrapper -->

  <div class="col-sm-4">

    <div class="date">
      <span class="month">August</span>
      <h1 class="day">28</h1>
    </div>

  </div>

  <div class="col-sm-8"><!-- this column holds all the Events for this Date -->

    <div class="jumbotron">
        <h4>Sample Title</h4>
        <p>IT Thesis defense</p>
        <h6>7:00 AM - 8:00 PM</h6>
    </div>

  </div>

</div>

注意:新结构将需要对您的某些CSS width属性进行一些调整,而我在“日期”和“事件”列上输入的col- /设备只是示例-根据需要的大小。

暂无
暂无

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

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