【发布时间】:2018-03-12 07:52:28
【问题描述】:
我有一个 CSS 文件,其代码如下所示...
.button{
width: 700px;
height: 100px;
text-align: center;
display: inline-block;
font-size: 50px;
font-family: Gauge;
color: white;
border: rgba(255,255,255,0.3) 11px solid;
box-shadow: 0 5px 10px white;
text-shadow: 0 0 10px #000;
margin: 15px 15px 15px 15px;
transition: 0.4s
}
button.oneshot{
background: linear-gradient(rgba(0,0,0,1),rgba(0,0,0,0.4),rgba(0,0,0,1)) no-repeat center center fixed,
url("oneshot.png") center 60%;
button.lisatp{
background: linear-gradient(rgba(0,0,0,1),rgba(0,0,0,0.4),rgba(0,0,0,1)) no-repeat center center fixed,
url("lisa the painful.jpg") 45% 60%;
}
...
...
如您所见,子类 oneshot 和 lisatp 中有一行重复:
linear-gradient(rgba(0,0,0,1),rgba(0,0,0,0.4),rgba(0,0,0,1)) no-repeat center center fixed
但是,由于每个子类也有一个图像作为背景,所以我找不到将重复的行放在.button 中的方法。
是否有可能以某种方式进一步简化这一点,或者这是否尽可能简单?
【问题讨论】:
-
是的,你可以,你需要使用多个背景。请注意,并非所有浏览器都支持它! developer.mozilla.org/en-US/docs/Web/CSS/…
-
@GhostPengy 你可能注意到他已经在使用多个背景了
标签: html css background linear-gradients