【发布时间】:2013-07-11 20:16:06
【问题描述】:
我将如何在无序列表中的项目符号之间画一条垂直线,如下所示:
请注意,该行在最后一个列表项目符号处停止。我使用list-style:none; 和图像作为项目符号。 HTML 如下所示:
<ul class="experiences">
<!-- Experience -->
<li class="green">
<div class="where">New York Times</div>
<h3 class="what green">Senior Online Editor</h3>
<div class="when">2012 - Present</div>
<p class="description">Jelly-o pie chocolate cake...</p>
</li>
...
按要求提供 CSS 代码:
/* Experiences */
ul.experiences {
padding-left: 15px;
margin-top: -1px;
}
ul.experiences li {
padding-left: 33px;
margin-bottom: 2.5em;
list-style: none;
background: url('../img/misc/list-bullet-darkgray.png') no-repeat;
}
ul.experiences li.green {
background: url('../img/misc/list-bullet-green.png') no-repeat;
}
ul.experiences li.blue {
background: url('../img/misc/list-bullet-blue.png') no-repeat;
}
ul.experiences li.pink {
background: url('../img/misc/list-bullet-pink.png') no-repeat;
}
.where {
font-size: 1.2857em; /* 18/16 -> 18px */
font-weight: 300;
display: inline;
margin-right: 0.5em;
}
.what {
font-size: 0.75em; /* 12/16 -> 12px */
font-weight: 700;
text-transform: uppercase;
color: #fff;
background-color: #444444;
display: inline-block;
padding: 0 12px;
margin: -5px 0.5em 0 0 !important;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.what.green {
background-color: #c4df9b;
}
.what.blue {
background-color: #6dcff6;
}
.what.pink {
background-color: #f06eaa;
}
.when {
float: right;
color: #b9b9b9;
font-style: italic;
}
.description {
display: block;
margin-top: 0.5em;
}
【问题讨论】:
-
我相信您可以使用
.experiences li:last-child来-不-显示左边框,而您可以使用.experiences li在其余部分的左侧显示边框 -
@Sumurai8 这样,边框就不会下到最后一个子弹了。
-
那么,你解决了这个问题吗?如果您使用了本页提供的解决方案,请考虑将其标记为已接受的答案。
-
抱歉耽搁了,我有一段时间没时间看这个了。请参阅我对您的回答的评论。
标签: css list html-lists