CSS3包络形状 [英] CSS3 envelope shape
问题描述
正如你可能已经猜到的,这个图像是邮件信封形状的一部分,如果可能,我想用CSS3创建。我做了其他部分,但这一个棘手。形状需要在两侧都有三角形切割和圆角(可能是border-radius-bottom-left / border-radius-bottom-right)。
As you might have guessed this image is part of a mail envelope shape which I would like to create with CSS3 if possible. I've made the other parts but this one's tricky. The shape needs both a triangular cut on both sides and rounded corners (presumably border-radius-bottom-left/border-radius-bottom-right). It also has to have the ability to cast a small shadow.
这是我到目前为止所做的 -
This is what I've done so far -
#envelope {
background: #fff;
}
.closed {
width: 860px;
height: 0;
border-top: 80px solid fff;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
-moz-box-shadow: 0 1px 5px #ccc;
-webkit-box-shadow: 0 1px 5px #ccc;
box-shadow: 0 1px 5px #ccc;
}
jsFiddle - http://jsfiddle.net/hsYUy/
jsFiddle - http://jsfiddle.net/hsYUy/
推荐答案
我只使用了Chrome的阴影和旋转属性,但您可以将其添加到其他浏览器中,
My attempt, I only used the shadow and rotate properties for chrome, but you can add it for other browsers,
body {
background: #f2f2f2;
}
#content {
width: 460px;
margin: 0 auto;
background: #fff;
height: 400px;
/* for demo */
-moz-box-shadow: 0 1px 5px #ccc;
-webkit-box-shadow: 0 1px 5px #ccc;
box-shadow: 0 1px 5px #ccc;
border-bottom-left-radius: 15px;
-moz-border-radius-bottomleft: 15px;
-webkit-border-bottom-left-radius: 15px;
border-bottom-right-radius: 15px;
-moz-border-radius-bottomright: 15px;
-webkit-border-bottom-right-radius: 15px;
z-index: 0;
}
.closed {
z-index: 1;
width: 460px;
overflow: hidden;
margin: 0 auto;
height: 80px;
margin-bottom: -5px;
}
.closed .mid {
/*background: #fff;*/
width: 360px;
margin: 0 auto;
margin-top: -70px;
height: 80px;
background-color: #fff;
-moz-box-shadow: 0 1px 5px #ccc;
-webkit-box-shadow: 0 1px 5px #ccc;
box-shadow: 0 1px 5px #ccc;
-webkit-border-radius: 12px;
}
.left,
.right {
display: none;
}
.closed .right {
display: block;
width: 0;
height: 100px;
border-left: 60px solid #fff;
border-right: 1px solid #ccc;
margin-left: 384px;
-webkit-transform: rotate(39deg);
margin-top: -34px;
box-shadow: 1px -1px 1px #ccc;
}
.closed .left {
display: block;
width: 0;
height: 100px;
border-right: 60px solid #fff;
border-left: 1px solid #ccc;
margin-left: 16px;
-webkit-transform: rotate(-39deg);
margin-top: -100px;
box-shadow: -1px -1px 1px #ccc;
}
<div id="content">
<div class="closed">
<div class="right"></div>
<div class="left"></div>
<div class="mid"></div>
</div>
</div>
这篇关于CSS3包络形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!