问题
I want an arrow on the left and right side of a div. Like here, but on both sides: http://cssarrowplease.com/
Is that possible?
回答1:
Add an extra div inside .arrow
, on which you add a :before
and :after
pseudo class as well. (Note: the extra div is necessary because of the extra border. The border is created by creating two overlapping divs, :before
and :after
)
.arrow_box {
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
width: 200px;
}
.arrow_box:after, .arrow_box:before {
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
.arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #88b7d5;
border-width: 30px;
left: 50%;
margin-left: -30px;
}
.arrow_box:before {
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 36px;
left: 50%;
margin-left: -36px;
}
.arrow_box > div:after, .arrow_box > div:before {
top: 100%;
border: solid transparent;
content: "";
height: 0;
width: 0;
position: absolute;
}
.arrow_box > div:after {
border-color: rgba(136, 183, 213, 0);
border-top-color: #88b7d5;
border-width: 30px;
left: 50%;
margin-left: -30px;
}
.arrow_box > div:before {
border-color: rgba(194, 225, 245, 0);
border-top-color: #c2e1f5;
border-width: 36px;
left: 50%;
margin-left: -36px;
}
<div class="arrow_box">
<div>
bla!<br />
bla!<br />
bla!<br />
bla!<br />
bla!<br />
bla!<br />
</div>
</div>
And a demo.
来源:https://stackoverflow.com/questions/18722059/adding-an-arrow-on-both-sides-of-a-div-using-css