[CSS]background背景
css背景样式
序号 中文说明 标记语法
1 背景颜色 {background-color:数值}
2 背景图片 {background-image: url('imgpath/img.png')|none}
3 背景重复 {background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
4 背景固定 {background-attachment:fixed|scroll}
5 背景定位 {background-position:数值|top|bottom|left|right|center}
6 背影样式 {background:背景颜色|背景图象|背景重复|背景附件|背景位置}
1.背景颜色:background-color
语法: {background-color:数值}
说明: 参数取值和颜色属性一样
注意: 在 HTML当中,要为某个对象加上背景色只有一种办法,那就是先做一个表格,在表格中设置完背景色,再把对象放进单元格。这样做比较麻烦,不但代码较多,还要为表格的大小和定位伤些脑筋。现在用CSS就可以轻松地直接搞定了,而且对象的范围很广,可以是一段文字,也可以只是一个单词或一个字母。
例子: <span style="background-color:red">给部分文字加背景颜色</span>给部分文字加背景颜色
表格背影颜色:style="background-color:red"
2.背景图片:background-image
语法: {background-image: url(http://www.jb51.net/URL)|none}
说明: URL就是背景图片的存放路径。如果用“none”来代替背景图片的存放路径,将什么也不显示。
例子: 给部分文字加背景图片 .imgbgstyle { background-image: url(http://www.jb51.net/logo.gif)}
3.背景重复:background-repeat
语法: {background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}
作用: 背景图片重复控制的是背景图片平铺与否,也就是说,结合背景定位的控制可以在网页上的某处单独显示一幅背景图片
说明: 参数取值范围:
·inherit 继承
·no-repeat 不重复平铺背景图片
·repeat
·repeat-x 使图片只在水平方向上平铺
·repeat-y 使图片只在垂直方向上平铺
注意: 如果不指定背景图片重复属性,浏览器默认的是背景图片向水平、垂直两个方向上平铺。
4.背景固定:background-attachment
语法: {background-attachment:fixed|scroll}
说明: 参数取值范围
·fixed:网页滚动时,背景图片相对于浏览器的窗口而言,固定不动
·scroll:网页滚动时,背景图片相对于浏览器的窗口而言,一起滚动
注意: 背景图片固定控制背景图片是否随网页的滚动而滚动。如果不设置背景图片固定属性,浏览器默认背景图片随网页的滚动而滚动。为了避免过于花哨的背景图片在滚动时伤害浏览者的视力,所以可以解除背景图片和文字内容的捆绑,该为和浏览器窗口捆绑。
例子: 使背景图案不随文字“滚动”的CSS
BODY { background: purple url(http://www.jb51.net/bg.jpg); background-repeat:repeat-y; background-attachment:fixed }
5.背景定位:background-position
语法: {background-position:数值|top|bottom|left|right|center}
作用: 背景定位用于控制背景图片在网页中显示的位置。
说明: 参数取值范围
·带长度单位的数字参数
·top:相对前景对象顶对齐
·bottom:相对前景对象底对齐
·left:相对前景对象左对齐
·right:相对前景对象右对齐
·center:相对前景对象中心对齐
·比例关系
关键字解释如下:
top left = left top = 0% 0%
top = top center = center top = 50% 0%
right top = top right = 100% 0%
left = left center = center left = 0% 50%
center = center center = 50% 50%
right = right center = center right = 100% 50%
bottom left = left bottom = 0% 100%
bottom = bottom center = center bottom = 50% 100%
bottom right = right bottom = 100% 100%
[CSS]background背景的更多相关文章
- css background 背景知识详解
background 背景属性 我们知道元素有前景色color,与之对应的还有背景色,通过background我们可以为元素添加实色(background-color)和任意多个背景图片(backgr ...
- css background 背景图设置
- CSS 背景-CSS background
这里有个很好的样式学习网站:http://www.divcss5.com/rumen/r125.shtml 一.Css background背景语法 - TOP CSS背景基础知识 CSS 背 ...
- css中background背景属性概
css中background背景属性概 background:url(背景图片路径) no-repeat;/*不重复默认在左上方*/background:url(背景图片路径) no-repeat ...
- css 使用background背景实现border边框效果
css中,我们一般使用border给html元素设置边框,但也可以使用background背景来模拟css边框效果,本文章向大家介绍css 使用background背景实现border边框效果,需要的 ...
- CSS样式表之background背景
[CSS常用背景属性]:background (缩写形式) background-color:背景色 background-image:背景图 url中放图片地址,背景图和背景色同时存在时,背景图覆 ...
- css background之设置图片为背景技巧
css background之设置图片为背景技巧-css 背景 Background是什么意思,翻译过来有背景意思.同样在css里面作为css属性一成员同样是有背景意思,并且是设置背景图片.背景颜色. ...
- CSS background 之设置图片为背景技巧
首先先来看看background有那些值: 可以按顺序设置如下属性(可点击进入相应的css手册查看使用):background-color 背景颜色background-image 背景图片backg ...
- (转)HTML&CSS——background: url() no-repeat 0 -64px;CSS中背景图片定位方法
http://blog.csdn.net/oscar92420aaa/article/details/51304067 CSS中背景图片的定位,困扰我很久了.今天总算搞懂了,一定要记下来. 在CSS中 ...
随机推荐
- hdoj 1789 Doing Homework again
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- windows mobile 6.5 隐藏 左下角(左上角)的开始按钮 叉号关闭按钮
其实做起来很简单,但是国内的网站就是找不到. 1.开始按钮原来的界面是这样的: windows mobile 6.0界面: windows mobile 6.5.X界面: 修改一个windows mo ...
- SpringMVC 常用注解
本文参考了博客,具体请见:http://www.cnblogs.com/leskang/p/5445698.html Spring MVC的常用注解 1.@Controller @Controller ...
- table 的thead th 固定 tbody滚动例子
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- C#验证邮件
public static bool IsEmail(string email) { String strExp = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+( ...
- Android面向HTTP协议发送post请求
/** * 採用post请求的方式 * * @param username * @param password * @return null表示求得的路径有问题,text返回请求得到的数据 */ pu ...
- 查看数据库中有哪些活动的事务,对应的会话id,执行的语句
select dbt.database_id, DB_NAME(dbt.database_id) '数据库名', dbt.transaction_id, at.name, at.transaction ...
- 在Eclipse中怎样公布创建的JavaWebproject
博客<在Eclipse中怎样创建JavaWebproject>中图文并茂的说明了Eclipse中创建JavaWebproject的方法:博客<怎样为Eclipse开发工具中创建的Ja ...
- mysql加入�管理员
1.首先用超级管理员登录,然后点击权限button 2.点击加入�新用户,填写登录名和password,全局权限不用选,点击新建用户button 3.编辑新加入�的用户(编辑权限) 4.找到" ...
- SQLServer怎样导入excel
--从Excel文件里,导入数据到SQL数据库中,非常easy,直接用以下的语句: /*======================================================== ...