首先毋庸置疑,当背景是图片的时候可以利用background属性,
写法可以是 background:url();
或者是background-image:url()
业务中在设置button的背景为图片的时候,因为前面button有样式 background:red !important
所以在修改背景的时候也要加上了!importan,否则背景样式会设置不成功,仍然保持原来的。
所以写成了:background: url(...) !important
但是再利用background-size设置背景图片的大小就无效。原因正是设置了background为!important,
上面是background的介绍,显然这个属性是多个属性的简写,background包含了background-size,所以当给background设置!important,再设置background-size自然无效。