元素背景,颜色和图像,是否可能?

时间:2014-03-22 13:07:23

标签: jquery html css html5 css3

我想知道是否可以同时拥有背景颜色和元素图像。

喜欢这样:

background:#666;
background:url("nav-icon") no-repeat;
right:10px; top:10px;

目前它忽略了第一个背景声明:background:#666;

谢谢杰克

2 个答案:

答案 0 :(得分:3)

background是所有背景样式的速记属性,请尝试:

background: #666 url("nav-icon") 10px 10px no-repeat;

参考:https://developer.mozilla.org/en-US/docs/Web/CSS/background

答案 1 :(得分:0)

是您可以使用

提供完整的属性名称,例如

   background-color:#666; ( instead of only background)

   background-image:url('nav-icon');
   background-repeat:no-repeat;
   background-position:10px 10px 0 0;