css div 边缘渐变,围绕div的CSS3渐变边框
3 個答案:
答案 0 :(得分:1)
我建議使用border-image屬性
.top-to-bottom {
border-bottom: 10px solid trasparent;
border-width: 10px;
border-style: solid;
-webkit-border-image: -webkit-gradient(linear, 0 0, 0 100%, from(black), to(rgba(0, 0, 0, 0))) 1 100%;
-webkit-border-image: -webkit-linear-gradient(#FBCDEA, rgba(0, 0, 0, 0)) 1 1;
-moz-border-image: -moz-linear-gradient(#FBCDEA, rgba(0, 0, 0, 0)) 1 1;
-o-border-image: -o-linear-gradient(#FBCDEA, rgba(0, 0, 0, 0)) 1 1;
border-image: linear-gradient(to bottom, #FBCDEA, rgba(0, 0, 0, 0)) 1 1;
height: 100px;
width: 97%;
border-top: 10px solid #FBCDEA;
}
.bottom-to-top {
border-top: 10px solid trasparent;
border-width: 10px;
border-style: solid;
-webkit-border-image: -webkit-gradient(linear, 0 100%, 0 0, from(#FBCDEA), to(rgba(0, 0, 0, 0))) 1 1;
-webkit-border-image: -webkit-linear-gradient(bottom, black, rgba(0, 0, 0, 0)) 1 1;
-moz-border-image: -moz-linear-gradient(bottom, #FBCDEA, rgba(0, 0, 0, 0)) 1 1;
-o-border-image: -o-linear-gradient(bottom, #FBCDEA, rgba(0, 0, 0, 0)) 1 1;
border-image: linear-gradient(to top, #FBCDEA, rgba(0, 0, 0, 0)) 1 1;
border-bottom: 10px solid #FBCDEA;
height: 100%;
width: 98%
}
答案 1 :(得分:1)
既然你想要純css,這就是一種方式:
.dblgradbox {
margin: auto;
padding: 15px;
width: 275px;
height: 200px;
border: 15px solid transparent;
border-top: 10px solid transparent;
border-image: linear-gradient(to bottom, transparent, #FBCDEA) 3 100%;
box-shadow: 0 15px 0 0 #FBCDEA, 0 -5px 0 0 #F7FCFF, inset 0px 15px 0 0 #FBCDEA;
background-image: linear-gradient(#FBCDEA, transparent), linear-gradient(#FBCDEA, transparent);
background-size: 15px 100%;
background-position: 0 0, 100% 0;
background-repeat: no-repeat;
border-radius: 7px;
}
x3ns
運行代碼段后查看“整頁”。我沒有包含任何跨瀏覽器屬性,因為這是一個例子。
此方法通常通過應用漸變邊框,并使用盒陰影插入技術來幫助完成元素內(nèi)的效果 - 因此還需要填充以適合其中的內(nèi)容。背景圖像僅在插圖的兩側(cè)顯示兩個漸變條。
答案 2 :(得分:0)
也許是這樣?
*{
box-sizing: border-box;
}
.wrap{
width: 300px;
height: 300px;
padding: 20px;
margin: 25px auto;
border-radius: 10px;
background: rgb(254,249,253); /* Old browsers */
background: -moz-linear-gradient(top, rgb(254,249,253) 0%, rgb(253,230,246) 50%, rgb(253,204,234) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(254,249,253)), color-stop(50%,rgb(253,230,246)), color-stop(100%,rgb(253,204,234))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgb(254,249,253) 0%,rgb(253,230,246) 50%,rgb(253,204,234) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgb(254,249,253) 0%,rgb(253,230,246) 50%,rgb(253,204,234) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgb(254,249,253) 0%,rgb(253,230,246) 50%,rgb(253,204,234) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgb(254,249,253) 0%,rgb(253,230,246) 50%,rgb(253,204,234) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fef9fd', endColorstr='#fdccea',GradientType=0 ); /* IE6-9 */
}
.wrap div{
width: 100%;
height: 100%;
padding: 20px;
}
.wrap .inner{
background: rgb(253,204,234); /* Old browsers */
background: -moz-linear-gradient(top, rgb(253,204,234) 0%, rgb(253,230,246) 50%, rgb(254,249,253) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(253,204,234)), color-stop(50%,rgb(253,230,246)), color-stop(100%,rgb(254,249,253))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgb(253,204,234) 0%,rgb(253,230,246) 50%,rgb(254,249,253) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgb(253,204,234) 0%,rgb(253,230,246) 50%,rgb(254,249,253) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgb(253,204,234) 0%,rgb(253,230,246) 50%,rgb(254,249,253) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgb(253,204,234) 0%,rgb(253,230,246) 50%,rgb(254,249,253) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdccea', endColorstr='#fef9fd',GradientType=0 ); /* IE6-9 */
}
.wrap .item{
background: #fff;
}
總結(jié)
以上是生活随笔為你收集整理的css div 边缘渐变,围绕div的CSS3渐变边框的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 根据服务器ip地址查看虚拟目录,IIS虚
- 下一篇: css入门教程 网页首字下沉,CSS制作