2017-05-29 63 views
0

我需要的是这样的:如何创建垂直时间表

Picture of vertical academic timeline. The listed major is on one side of a center vertical line with the dates on the other side. Which side the major and dates are on alternates. Each entry also has a motorboard hat on the vertical line.

正如你可以看到主要的一个是正确的,接下来是在左边,等几年这样做。

我写了这个HTML & CSS代码:

.full div { 
 
    display: inline-block; 
 
    width: 130px; 
 
    height: 50px; 
 
} 
 

 
.full div:nth-child(odd) { 
 
    float: left; 
 
}
<div class="row"> 
 
    <div class="full"> 
 
    <div class="d1">university 1</div> 
 
    <div class="d2">year 1</div><br> 
 
    <div class="d1">university 2</div> 
 
    <div class="d2">year 2</div><br> 
 
    <div class="d1">university 3</div> 
 
    <div class="d2">year 3</div><br> 
 
    <div class="d1">university 4</div> 
 
    <div class="d2">year 4</div><br> 
 
    </div> 
 
</div>

乍一看是的,它的正常工作如我所料,但事实并非如此。

的问题是:

  1. 我不能中心对齐没有母校我做什么。

  2. 在超小尺寸div下降,不是并排。

  3. 如果我使用像col-xs-6这样的类,它不会像我那样工作。

JSFiddle

只是调整窗口明白我在说什么。

+0

注意。 ''div class =“row”>'中的任何内容也应该位于'.col'中。在你的问题中,你把它放在一行中,但不是一列。 *内容应放在列中,并且只有列可能是行的直接子节点。* - http://getbootstrap.com/css/ – BSMP

回答

1

选中此项:希望它接近您的需要。你没有正确使用引导网格系统

https://jsfiddle.net/zke68ao2/1/

.full{ 
    display: inline-block; 
} 
.full div{ 
     display: inline-block; 
     width: 130px; 
     height: 50px; 
     text-align:center; 
    } 

    .full div:nth-child(odd):not(br){ 
     float: left; 
    } 
    .full div:nth-child(even):not(br){ 
     float: right; 
    } 
+0

感谢兄弟。我只需更新我的代码,它的工作正常:)。你可以检查我的在线代码,如果你想。再次感谢 – siros