我是前台开发人员的新手,我使用的是sass。我有我的自定义时间表,我需要帮助,使位置与年和时间标记。我还想把图像描述放在图像的右边。
这是我弹琴的链接
https://jsfiddle.net/g99Lmsaz/
这是我的sass代码
$purple: #AF80ED;
$gray: #f2f2f2;
$white: #ffffff;
$timeline-gray: #dddddd;
.event {
background: $purple;
display: table;
width: 100%;
margin: 0 auto;
}
.event-2 {
background: $gray;
display: table;
width: 100%;
}
time {
/*float: left;
position: absolute;
top: 40%;*/
display: table-cell;
width: auto;
text-align: center;
vertical-align: middle;
width: 25%;
}
.timeline ul li {
list-style-type: none;
position: relative;
width: 6px;
/*left: 10%;
margin: 0 auto;*/
padding: 10px 0 10px 0;
background: $timeline-gray;
.content {
position: relative;
left: 20px;
max-width: 700px;
top: calc(100% / 2 - 10px);
img{
border-radius: 50%;
height: 20px;
width: 20px;
}
}
}
.timeline ul li::after {
content: '';
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 15px;
height: 15px;
border: 4px solid $timeline-gray;
border-radius: 50%;
background: $white;
top: calc(100% / 2 - 10px);
}html代码
<section class="timeline">
<ul>
<div class='event'>
<time>1934</time>
<li>
<div class='content'>
<p>
Paris
</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg/240px-Tour_Eiffel_Wikimedia_Commons_%28cropped%29.jpg" >
<p>
Eiffel Tower
</p>
</div>
</li>
</div>
<div class='event-2'>
<time>1934</time>
<li>
<div class='content'>
<p>
asdsadsadsadsad
</p>
</div>
</li>
</div>
</ul>
</section>发布于 2017-06-07 09:03:57
您的HTML结构是错误的,您不应该直接在div标记中添加ul
ul标签必须有li标签在里面,然后你可以把你想要的东西放进李里面。
我更改了代码中的一些内容,最好在time标记上使用伪元素,而不是在li上使用伪元素。
https://stackoverflow.com/questions/44407822
复制相似问题