background 属性其实包括:background-image, background-color, background-position, background-repeat, background-attachment
当然可以用简单的方法写啦。
就好像border属性,可以简写成 selector {border: 1px solid red;} 这里就包括了 border-width, border-style, border-color.
background-attachment有2个值scroll 和 fixed。
对于background可以写成这样 selector{background: url("pic.jpg") red 50% repeat fixed }
补充一下,background-color可以有RGD,hex,或者直接写颜色,比如red,green。到底这3种方法有什么不同,我还没搞明白?在实际中三种我都看过。哪种比较好呢??谁能告诉我?
不能忘记说的是background-color可以设置成transparent,透明。
background的默认值应该是这样:
{background: transparent none repeat scroll 0% 0%}