1

我真的很喜欢 branch.com 上的箭头框,例如:http ://tinyurl.com/lw5zlhu

如何使用 branch.com 之类的时间线创建箭头框?

我已经这样做了:http: //jsfiddle.net/uFPEf/6/

HTML

<div class="item">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
       Curabitur adipiscing dignissim purus at adipiscing.
    </p>
</div>
<div class="timeline">
    <div class="line"></div>
</div>
<div class="item">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
       Curabitur adipiscing dignissim purus at adipiscing.
    </p>
</div>
<div class="timeline">
    <div class="line"></div>
</div>
<div class="item">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
       Curabitur adipiscing dignissim purus at adipiscing.
    </p>
</div>

CSS

body {
    font-family: "HelveticaNeue-Light", "Helvetica Neue Light", 
    "Helvetica Neue", Helvetica, Arial, "Lucida Grande", 
    sans-serif; 
    font-weight: 300;
    padding:20px;
}
.item{ 
    border-radius:3px; 
    padding:10px; 
    border: solid 1px #EEEEEE; 
}
.item p {
    color:#333333;
    padding:20px;
}

.timeline { 
    width: 100%;
}

.line {
    background: #EEEEEE;
    height: 50px;
    margin: 0 auto;
    width: 2px;
}
4

2 回答 2

3

您可以在元素之前和之后使用 CSS'。如果您使用绝对定位直接定位到您想要的位置,并提供白色背景,您可以模仿它。

.item:before {
    position: absolute;
    top: -11px;
    left: 50px;
    -webkit-transform: rotate(45deg);
    height: 20px;
    width: 20px;
    background: #fff;
    border-top: 1px solid #aaa;
    border-left: 1px solid #aaa;
    content: '';
}
.item:after {
    position: absolute;
    bottom: -11px;
    left: 50px;
    -webkit-transform: rotate(45deg);
    height: 20px;
    width: 20px;
    background: #fff;
    border-top: 1px solid #aaa;
    border-left: 1px solid #aaa;
    content: '';
}

http://jsfiddle.net/uFPEf/7/

于 2013-07-24T00:04:55.947 回答
0

Here is a pure CSS solution it may be better to use a image though.

HTML:

<div id="box"></div>

CSS:

#box{
    width:200px;
    height:200px;
    background:#EEE;
    box-shadow: 0px 0px 2px #999;
    margin:50px;
    position:relative; /* This makes sure the ::after is absolute to this element */
}

#box:after{
    content:''; /* Content is required on all ::before & ::after */
    width:22px;
    height:22px;
    background:#FFF;
    border-top: 1px solid #C2C1C1; /* 3D'ish effect */
    border-left:1px solid #C2C1C1;
    position:absolute;
    bottom:-12px;  /* Half the height of the square */
    left:15px;
    -webkit-transform: rotate(45deg);  /* rotate 45deg to fake a triangle */
}

Demo

于 2013-07-24T00:07:11.827 回答