在CSS頁面中的背景顏色是透過background-color屬性來實現的,幾乎所有HTML元素的背景色都可以透過它來設置。例: <style type="text/css"> #view{ width:330px; height:50px; background-color:#22072c; /* 設置背景色 */ } </style> <div id="view"> </div> 在CSS頁面中的背景圖片是透過background-image屬性來實現的。例: <style type="text/css"> #view{ width:330px; height:50px; background-image: url(/public/images/ch03/pic1.jpg); /* 背景圖片 * / } </style> <div id="view"> </div> 在CSS頁面中的背景圖片重複是透過background-repeat屬性來實現的。包括: 水平重複(repeat-x)、垂直重複(repeat-y)、不重複(no-repeat)。例: <style type="text/css"> #view{ width:330px; height:50px; background-image: url(/public/images/ch03/pic1.jpg); /* 背景圖片 * / background-repeat: repeat-y; /* 垂直方向重複 */ } </style> <div id="view"> </div>
|
B05.HTML 5, jQuery, Facebook & GWT > 04.CSS >