CSS中background属性详解

CSS背景属性 background css 说明 background-image:url(图片的网址); 背景图 background: url( 图片的网址 ); 背景 background-color:#色码; 背景色彩 Exp: background-image:url(背景图案.jpg,gif,bmp); background-color:#FFFFFF; background-color : tra

CSS背景属性 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("http://www.dedecms.com/xx.gif");
background-repeat:no-repeat;
以http://www.dedecms.com/xx.gif这张图片为背景,当图片大小不够的时候,不并排重复

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

background-attachment是否固定图片位置

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

Exp:
background-image:url("http://www.dedecms.com/xx.gif");
background-repeat:no-repeat;
background-attachment:fixed;
以http://www.dedecms.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

background-clip 属性

规定背景的绘制区域:

div
{
background-color:yellow;
background-clip:content-box;
}

border-box,padding-box,content-box

CSS background-size 属性详解

摘要:  cssbackground-size 属性详解,background-size 指定背景图像大小,以象素或百分比显示,当指定为百分比时,大小会由所在区域的宽度、高度以及 background-origin 的位置决定,还可以通过 cover 和 contain 来对图片

css background-size 属性详解,background-size
指定背景图像大小,以象素或百分比显示,当指定为百分比时,大小会由所在区域的宽度、高度以及 background-origin
的位置决定,还可以通过 cover 和 contain 来对图片进行伸缩。

background-size 属性

1、定义:

background-size 用来调整背景图像的尺寸大小。

2、语法:

以下为引用内容:
background-size : contain | cover | 100px 100px | 50% 100%;

3、参数:

background-size:contain; // 缩小图片来适应元素的尺寸(保持像素的长宽比);
   
background-size :cover; // 扩展图片来填满元素(保持像素的长宽比);
   
background-size :100px 100px; // 调整图片到指定大小;
   
background-size :50% 100%; // 调整图片到指定大小,百分比相对于包含元素的尺寸。

4、浏览器兼容:

IE
和遨游不支持;
    Firefox
添加私有属性 -moz-background-size 支持;
    Safari 和
Chrome 添加私有属性 -webkit-background-size 支持;
    Opera 不支持
background-size 属性,添加其私有属性 -o-background-size 也不支持。

5、示例:

以下为引用内容:
div{
   background:#00ff00
url(img.jpg) no-repeat;
   background-size:60% 80%;
   -moz-background-size:60%
80%;
   -webkit-background-size:60%
80%;
   -o-background-size:60%
80%;
}

时间: 2024-07-30 09:38:40

CSS中background属性详解的相关文章

DIV css中cursor属性详解-鼠标移到图片变换鼠标形状 (转)

css中cursor属性详解-鼠标移到图片变换鼠标形状 语法: cursor : auto | all-scroll | col-resize| crosshair | default | hand | move | help | no-drop | not-allowed | pointer | progress | row-resize | text | vertical-text | wait | *-resize | url ( url )  取值: auto  :   默认值.浏览器根

CSS中margin属性详解

margin属性概述margin是CSS层叠样式表中用来规定围绕在元素边框周围空白区域范围的属性. 该接受任何长度单位,可以是像素.英寸.毫米或 em. 相关属性margin 可以单独改变元素的上,下,左,右边距.也可以一次改变所有的属性. 使用语法1.使用单独属性设置四边的距离 #d2 { border: 1px solid blue; /*为了显示效果,所以让d2有了边框 */ margin-top: 20px; /*上边距为20px*/ margin-right: 30px; /*右边距为

ImageView中scaleType属性详解

scaleType是指定图片的拉伸方式的一个属性,下面是具体的示例和介绍: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="

HTML中META属性详解 转载自 hero_213的博客

HTML中META属性详解 meta是html语言head区的一个辅助性标签.几乎所有的网页里,我们可以看到类似下面这段的html代码: <head> <meta   http-equiv= "content-Type "   content= "text/html;   charset=gb2312 "> </head>         也许你认为这些代码可有可无.其实如果你能够用好meta标签,会给你带来意想不到的效果,例如加

Android中shape属性详解

一.简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用. 1.新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为:shape_radius.xml 内容是这样的:(先不需要理解,先看shape怎么用) [html] view plaincopyprint? <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="ht

spring sessionFactory 属性配置详解,applicationContext中各种属性详解

1.Bean的id为sessionFactory,对应的类为AnnotationSessionFactory,即采用注解的形式实现hibernate. 2.hibernateProperties,配置hibernate的属性 1)hibernate.dialect,配置Hibernate方言,可以让Hibernate使用某些特定的数据库平台的特性,具体的dialect大全: 结下不同数据库的该属性的值如下表.其中属性值得格式:{hibernatejar的全名}.dialaect.{对应数据库}D

Hibernate 中配置属性详解(hibernate.properties)

Hibernate能在各种不同环境下工作而设计的, 因此存在着大量的配置参数.多数配置参数都 有比较直观的默认值, 并有随 Hibernate一同分发的配置样例hibernate.properties 来展示各种配置选项. 所需做的仅仅是将这个样例文件复制到类路径 (classpath)下并做一些自定义的修改. 属性1.Hibernate JDBC属性 属性名 用途 hibernate.connection.driver_class jdbc驱动类 hibernate.connection.ur

CSS background 属性详解

CSS background Property 语法: background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit; Note: If one of the properties in the shorthand declaration is the bg-size property, you must use a / (slash) to sep

Android中visibility属性详解

Android开发中,大部分控件都有visibility这个属性,其属性有3个分别为"visible "."invisible"."gone".主要用来设置控制控件的显示和隐藏. 1) 可见(visible) XML文件:android:visibility="visible"Java代码:view.setVisibility(View.VISIBLE); 2) 不可见(invisible) XML文件:android:vis