我可以用盒子阴影做这个吗?现在它是一个图像,但如果这可以用 css box-shadow 完成,我会受伤。
问问题
3849 次
3 回答
6
工作小提琴:http: //jsfiddle.net/sinhayash/7dPnQ/1/
.class {
height: 100px;
width: 100px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-top: 3px solid rgb(16, 130, 253);
border-bottom: 3px solid rgb(179, 216, 255);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgb(16, 130, 253)), to(rgb(179, 216, 255)));
background-image: -webkit-linear-gradient(#000, rgb(179, 216, 255));
background-image:
-moz-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
-moz-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255));
background-image:
-o-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
-o-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255));
background-image:
linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
linear-gradient(rgb(16, 130, 253),rgb(179, 216, 255));
-moz-background-size: 3px 100%;
background-size: 3px 100%;
background-position: 0 0, 100% 0;
background-repeat: no-repeat;
}
在火狐和铬上工作。
于 2013-06-17T12:45:21.213 回答
1
我不相信这可以通过box-shadow
边框和背景渐变的组合来完成。
div {
width: 400px;
padding: 20px 25px;
border-top: 5px solid #4672bb;
border-bottom: 5px solid #b8c9e5;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
margin: 40px auto;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ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JhdGVkKSIgLz4KPC9zdmc+);
background-image: -webkit-linear-gradient(#4672bb, #b8c9e5);
background-image:
-moz-linear-gradient(#4672bb, #b8c9e5),
-moz-linear-gradient(#4672bb, #b8c9e5)
;
background-image:
-o-linear-gradient(#4672bb, #b8c9e5),
-o-linear-gradient(#4672bb, #b8c9e5)
;
background-image:
linear-gradient(#4672bb, #b8c9e5),
linear-gradient(#4672bb, #b8c9e5)
;
-moz-background-size:5px 100%;
background-size:5px 100%;
background-position:0 0, 100% 0;
background-repeat:no-repeat;
}
SVG 使用出色的ColorZilla 渐变生成器生成
于 2013-06-17T12:36:14.590 回答
0
您可以将图像用作边框图像:http:
//jsfiddle.net/RRpcD/ jsfiddle 不喜欢此图像?codepen 怎么样:http: //codepen.io/gcyrillus/pen/Awihd
.gradient-border {
border-style: solid;
border-width: 2px 4px 4px 3px;
-moz-border-image: url(http://i.stack.imgur.com/O87Qx.png) 2 4 4 3 stretch;
-webkit-border-image: url(http://i.stack.imgur.com/O87Qx.png) 2 4 4 3 stretch;
-o-border-image: url(http://i.stack.imgur.com/O87Qx.png) 2 4 4 3 stretch;
border-image: url(http://i.stack.imgur.com/O87Qx.png) 2 4 4 3 fill stretch;
}
于 2013-06-17T13:28:16.977 回答