2015年12月6日 星期日

CSS - Background 心得 -- 20151207

Background性質有以下幾個:
  • background-color
  • background-image
  • background-repeat
  • background-attachment  (少用)
  • background-position



用法:background-color:屬性;

舉例:

<style>
h1 {
    background-color: Red;
}
p {
    background-color: #ff0000;
}
div {
    background-color: rgb(255,0,0);
}
</style>

※以上顏色的表示方法有三種。



用法:background-image:url("圖片路徑");
      
           搭配  background-repeat:屬性;    background-position:屬性; 



※background-repeat的屬性有三個:
  • no-repeat(不重複)
  • repeat-x(水平重複)
  • repeat-y(垂直重複)

舉例:

<style>
body{
    background-image:url("xxx.jpg");
    background-repeat:repeat-x;
    background-position:top right;
}
</style>





合併用法:background:顏色屬性  url("圖片路徑") 位置屬性 .....


舉例:

<style>
body{
background:red url("xxx.jpg") no-repeat top right;
}
</style>











沒有留言:

張貼留言