CSS中背景background的一些语法

来源:asp之家 时间:2009-03-24 21:02:00 

背景 background 

css  说明 
background-image:url("图片的网址");  背景图 
background: url(" 图片的网址 ");  背景  
background-color:#色码;  背景色彩  

Exp: 
background-image:url(背景图案.jpg,gif,bmp); 
background-color:#FFFFFF;  
background-color : transparent;    <--设定背景为透明色 

--------------------------------------------------------------------------------

background-repeat 改变背景图片的重复并排的设定 

css
 说明 
repeat  背景图片并排  
repeat-x  背景图片以X方向 并排  
repeat-y  背景图片以Y方向 并排  
no-repeat  背景图片不 以并排的方式处理  

Exp: 
background-image:url("https://www.aspxhome.com/xx.gif"); 
background-repeat:no-repeat; 
以https://www.aspxhome.com/xx.gif这张图片为背景,当图片大小不够的时候,不并排重复 

--------------------------------------------------------------------------------

background-attachment是否固定图片位置 

css
 说明 
scroll  拉动卷轴时,背景图片会跟着移动(缺省值)  
fixed  拉动卷轴时,背景图片不会跟着移动  

Exp: 
background-image:url("https://www.aspxhome.com/xx.gif"); 
background-repeat:no-repeat; 
background-attachment:fixed; 
以https://www.aspxhome.com/xx.gif背景图片不重复并列,且不随卷轴移动 

--------------------------------------------------------------------------------

以长度定位background-position: x y 
使用百分比定位 background-position: x% y% 

css
 说明 
x%  往右移  
y%  往下移  
backgroud-position: 0% 0%; 左边上方
backgroud-position: 0% 50%; 左边中间
backgroud-position: 50% 0%; 中间上方
backgroud-position: 50% 50%; 正中间
backgroud-position:100% 0%; 右边上方
backgroud-position: 0% 100%; 左边下方
backgroud-position: 100% 50%; 右边中间
backgroud-position: 50% 100%; 中间下方
backgroud-position: 100% 100%; 右边下方

以关键字定位 
关键字  说明  
top  上 ( y = 0 )  
center  中 ( x = 50, y = 50 )  
bottom  下 ( y = 100 )  
left  左 ( x= 0 )  

Exp: 
background-position:center; 
图片在指定背景中央X=50% Y=50%位置 
background-position: 200px 30px 

标签:css,语法,background,背景
0
投稿

猜你喜欢

  • Mysql触发器处理本表数据

    2010-10-25 19:56:00
  • CSS编写过程中常见的10个错误

    2008-05-29 12:49:00
  • 三种数据库利用SQL语句进行高效果分页

    2008-11-28 14:52:00
  • 详细讲解SQL Server数据库的文件恢复技术

    2009-01-15 12:54:00
  • 减少新开窗口提升可访问性

    2009-04-17 13:56:00
  • 停止密码输入掩饰?[译]

    2009-07-22 18:44:00
  • 使用Dreamweaver便捷技巧方法十六则

    2010-07-02 16:28:00
  • CSS教程:轻松解决表格的nobr问题

    2008-10-29 11:55:00
  • ie6 img onload

    2009-04-08 17:23:00
  • MySQL数据库配置技巧

    2009-03-06 14:32:00
  • oracle中的视图详解

    2009-12-22 11:48:00
  • 单击按钮将内容复制到剪贴板

    2008-08-22 13:08:00
  • 纯CSS3透明水晶盒

    2011-08-24 20:20:06
  • Web 标准设计实践:Google 的首页

    2008-10-12 12:14:00
  • Mootools常用方法扩展(二)

    2009-01-11 18:22:00
  • 用javascript实现Base64编码

    2008-03-04 16:51:00
  • MySQL 集群配置

    2009-04-20 14:15:00
  • ASP.NET中MD5和SHA1密码保护算法的使用

    2007-08-24 09:18:00
  • Yahoo!网站性能最佳体验的34条黄金守则——JavaScript和CSS

    2008-05-29 13:34:00
  • 禁用JavaScript脚本来复制网站内容

    2007-02-03 11:30:00
  • asp之家 网络编程 m.aspxhome.com