use*_*984 5 html css css-shapes
CSS 可以实现这样的功能吗?我已经尝试过使用 before/after 伪元素,虽然我可以得到一些适用于纯色的东西,但我很难想出一种方法来实现透明。

有什么建议?
如果您不需要每个项目周围的黑色边框(如发布的图像中所示),您仍然可以通过border如下方式创建所需的形状:
.timeline-unit:before, .timeline-unit:after {
top: 0;
border: solid transparent;
border-width: 1.65em;
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.timeline-unit:after {
content: " ";
left: 100%;
border-left-color: rgba(51, 51, 51, 0.8);
}
.timeline-unit {
position: relative;
display: inline-block;
background: rgba(51,51,51,.8);
padding: 1em;
line-height: 1.25em;
color: #FFF;
}
.timeline-unit:before { content: none; }
.timeline-unit + .timeline-unit:before {
content: " ";
border-color: rgba(51, 51, 51, 0.8);
border-left-color: transparent;
border-right: 0;
right: 100%;
}
.timeline-unit + .timeline-unit {
margin-left: 2em;
}
/************** D E M O **************/
body {
background: red;
-webkit-animation: bgcolor 4s linear 0s infinite alternate;
-moz-animation: bgcolor 4s linear 0s infinite alternate;
-o-animation: bgcolor 4s linear 0s infinite alternate;
animation: bgcolor 4s linear 0s infinite alternate;
}
@-webkit-keyframes bgcolor { from { background: red; } to { background: green; } }
@-moz-keyframes bgcolor { from { background: red; } to { background: green; } }
@-o-keyframes bgcolor { from { background: red; } to { background: green; } }
@keyframes bgcolor { from { background: red; } to { background: green; } }Run Code Online (Sandbox Code Playgroud)
<div class="timeline-unit"> Timeline 1 </div>
<div class="timeline-unit"> Timeline 2 </div>
<div class="timeline-unit"> Timeline 3 </div>Run Code Online (Sandbox Code Playgroud)
但是,如果您需要在每个项目上添加边框,则有两种选择:
drop-shadow()过滤器伪造边框 -示例在这里 (Webkit/Firefox35+ 支持)。border将不使用并可用于以后的使用(在 IE9+ 中也支持)。