【发布时间】:2014-09-24 02:10:39
【问题描述】:
我有一个完全有效的 (judging by the look) 径向渐变:
.square {
background-color: #f0d9b5;
color: #b58863;
width: 80px;
height: 80px;
float: left;
position: relative;
}
.grad:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #00f;
background: -webkit-radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
background: radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
background: -ms-radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
}
<div class="square grad"></div>
我对此没有任何问题,直到我发现all these prefixes are not needed for a gradient.。删除它们实际上会删除相应浏览器中的渐变。看起来问题是css gradient 有另一种(更新的)语法。
问题是,如果将我的背景更改为:
background: radial-gradient(circle at 50% 50% , #00f 0%, #fff 100%); 结果看起来不一样:
.square {
background-color: #f0d9b5;
color: #b58863;
width: 80px;
height: 80px;
float: left;
position: relative;
}
.grad-first:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #00f;
background: -webkit-radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
background: radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
background: -ms-radial-gradient(center center,circle cover,rgba(0,0,255,1),rgba(255,255,255,0)100%);
}
.grad-second:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #00f;
background: radial-gradient(circle at 50% 50% , #00f 0%, #fff 100%);
}
<div class="square grad-first"></div>
<div class="square grad-second"></div>
看起来它正在删除我在.square 上的第一个背景。怎么改?
【问题讨论】:
标签: html css gradient radial-gradients