1、background-position: 當背景圖很大時,可以讓其固定顯示在不同的位置。剩下的會隱藏。
引入背景圖片:background-image: url("img/banner.jpg");
background-position參數:
- 水平起始位置(left center right %)可以用這四種形式的任意一種
- 垂直起始位置(top center bottom %)可以用這四種形式的任意一種
實例:
1 background-position: right top;、、、、、、值的順序沒有關系 2 3 background-position: 40% center;、、、、、、、、百分比表示從圖的左邊向右邊的百分之多少開始顯示。 4 5 background-position: right;、、、、一個值表示從right邊的圖的中間開始顯示
2、background-attachment: fixed
固定定位相當於position:fixed
作用:用於固定背景圖
background-attachment: fixed; 必須是背景圖達到產生滾動條才會看到他的效果,否則不會起作用的