web 开发:CSS3 常用属性——速查手册!
web 开发:CSS3 常用属性——速查手册!
CSS3 简介:http://www.runoob.com/css3/css3-intro.html
1.目录
- background-position:
CSS Backgrounds and Borders Module Level 3
W3C Candidate Recommendation 9 September 2014
http://www.w3.org/TR/css3-background/#background-position
http://www.w3.org/TR/css3-background/#backgrounds
3.6. Positioning Images: the ‘background-position’ property
| Name: | background-position |
|---|---|
| Value: | <position> [ , <position> ]* |
| Initial: | 0% 0% |
| Applies to: | all elements |
| Inherited: | no |
| Percentages: | refer to size of background positioning area minus size of background image; see text |
| Media: | visual |
| Computed value: | A list, each item consisting of: a pair of offsets (horizontal and vertical) from the top left origin each given as a combination of an absolute length and a percentage |
| Animatable: | as repeatable list of simple list of length, percentage, or calc |
If background images have been specified, this property specifies their initial position (after any resizing) within their corresponding background positioning area.
Where
<position> = [
[ left | center | right | top | bottom | <percentage> | <length> ]
|
[ left | center | right | <percentage> | <length> ]
[ top | center | bottom | <percentage> | <length> ]
|
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
If only one value is specified, the second value is assumed to be ‘center’. If two values are given, a length or percentage as the first value represents the horizontal position (or offset) and a length or percentage as the second value represents the vertical position (or offset). <percentage> and <length> values here represent an offset of the top left corner of the background image from the top left corner of the background positioning area.
Note that a pair of keywords can be reordered while a combination of keyword and length or percentage cannot. So ‘center left’ is valid while ‘50% left’ is not.
If three or four values are given, then each <percentage> or<length> represents an offset and must be preceded by a keyword, which specifies from which edge the offset is given. For example, ‘background-position: bottom 10px right 20px’ represents a ‘10px’ vertical offset up from the bottom edge and a ‘20px’ horizontal offset leftward from the right edge. If three values are given, the missing offset is assumed to be zero.
Positive values represent an offset inward from the edge of the background positioning area. Negative values represent an offset outward from the edge of the background positioning area.
The following declarations give the stated (horizontal, vertical) offsets from the top left corner:
background-position: left 10px top 15px; /* 10px, 15px */
background-position: left top ; /* 0px, 0px */
background-position: 10px 15px; /* 10px, 15px */
background-position: left 15px; /* 0px, 15px */
background-position: 10px top ; /* 10px, 0px */
background-position: left top 15px; /* 0px, 15px */
background-position: left 10px top ; /* 10px, 0px */
- <percentage>
-
A percentage for the horizontal offset is relative to (width of background positioning area - width of background image). A percentage for the vertical offset is relative to (height of background positioning area - height of background image), where the size of the image is the size given by ‘
background-size’.For example, with a value pair of ‘
0% 0%’, the upper left corner of the image is aligned with the upper left corner of, usually, the box's padding edge. A value pair of ‘100% 100%’ places the lower right corner of the image in the lower right corner of the area. With a value pair of ‘75% 50%’, the point 75% across and 50% down the image is to be placed at the point 75% across and 50% down the area.
Diagram of the meaning of ‘
background-position: 75% 50%’. - <length>
- A length value gives a fixed length as the offset. For example, with a value pair of ‘
2cm 1cm’, the upper left corner of the image is placed 2cm to the right and 1cm below the upper left corner of the background positioning area. - ‘
top’ - Computes to ‘
0%’ for the vertical position if one or two values are given, otherwise specifies the top edge as the origin for the next offset. - ‘
right’ - Computes to ‘
100%’ for the horizontal position if one or two values are given, otherwise specifies the right edge as the origin for the next offset. - ‘
bottom’ - Computes to ‘
100%’ for the vertical position if one or two values are given, otherwise specifies the bottom edge as the origin for the next offset. - ‘
left’ - Computes to ‘
0%’ for the horizontal position if one or two values are given, otherwise specifies the left edge as the origin for the next offset. - ‘
center’ - Computes to ‘
50%’ (‘left 50%’) for the horizontal position if the horizontal position is not otherwise specified, or ‘50%’ (‘top 50%’) for the vertical position if it is.
The following ‘background’ shorthand declarations use keywords to set ‘background-position’ to the stated percentage values.
body { background: url("banner.jpeg") right top } /* 100% 0% */
body { background: url("banner.jpeg") top center } /* 50% 0% */
body { background: url("banner.jpeg") center } /* 50% 50% */
body { background: url("banner.jpeg") bottom } /* 50% 100% */
In the example below, the (single) image is placed in the lower-right corner of the viewport.
body {
background-image: url("logo.png");
background-attachment: fixed;
background-position: 100% 100%;
background-repeat: no-repeat;
}
Background positions can also be relative to other corners than the top left. E.g., the following puts the background image 10px from the bottom and 3em from the right:
background-position: right 3em bottom 10px
See the section “Layering multiple background images” for how ‘background-position’ interacts with other comma-separated background properties to form each background image layer.
2.
1
1
1
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxx
xxxxxxxxxxxxxx
web 开发:CSS3 常用属性——速查手册!
web 开发:CSS3 常用属性——速查手册!的更多相关文章
- 实用掌中宝--HTML&CSS常用标签速查手册 PDF扫描版
实用掌中宝--HTML&CSS常用标签速查手册 内容推荐: 本书第一篇以语法和实例相结合的形式,详细讲解了HTML语言中各个元素及其属性的作用.语法和显示效果:第二篇从CSS基本概念开始,分别 ...
- Docker常用命令速查手册(华贵铂金版)
原创声明:作者:Arnold.zhao 博客园地址:https://www.cnblogs.com/zh94 Docker常用命令速查手册 搜索仓库镜像 docker search nginx 获取 ...
- Delphi 7.0常用函数速查手册(磁盘文件类)
在Delphi 7.0中,已为我们定义好了非常多的函数,大致分类有6种:数据类型转换函数.字符串.数组操作函数.文件.磁盘操作函数.内存.指针操作函数.数学运算函数.日期函数. 在Delphi中调用函 ...
- Linux系统常用命令速查手册
点击上方"开源Linux",选择"设为星标" 回复"学习"获取独家整理的学习资料! 系统信息 arch #显示机器的处理器架构(1 ...
- Ubuntu常用命令速查手册-珍藏版-完整版
sudo apt-get install 软件名 安装软件命令 sudo nautilus 打开文件(有root权限) su root 切换到“root” ls 列出当前目录文件(不包括隐含文件) l ...
- Java程序员必会常用Linux速查手册
目錄 系统服务管理 文件管理 查看日志 压缩与解压 磁盘和网络管理 防火墙 ftp操作 软件的安装与管理 其他 系统服务管理 systemctl 输出系统中各个服务的状态: systemctl lis ...
- Git常用命令速查手册
Git组成 1.初始化仓库 git init 2.将文件添加到仓库 git add 文件名 # 将工作区的某个文件添加到暂存区 git add -u # 添加所有被tracked文件中被修改或删除的文 ...
- Git 常用命令速查手册
来源:https://www.jianshu.com/p/5ee9897b6b65 1.初始化仓库 git init 2.将文件添加到仓库 git add 文件名 # 将工作区的某个文件添加到暂存区 ...
- [Git]Git常用命令速查手册
看的别人的文章,来源:https://mp.weixin.qq.com/s/SGRcE9EPOu4Tph65tzPzQw
随机推荐
- vim编程配置方法
vim简介Vim 有以下几个模式:1) 正常(normal)模式,缺省的编辑模式:下面如果不加特殊说明,提到的命令都直接在正常模式下输入:任何其它模式中都可以通过键盘上的 Esc 键回到正常模式.2) ...
- spring security 3 自定义认证,授权示例
1,建一个web project,并导入所有需要的lib. 2,配置web.xml,使用Spring的机制装载: <?xml version="1.0" encoding=& ...
- 【sort】 基数排序
下面这段问答摘自csdn: 把基数排序说成桶排序应该是没有太大问题的.总的说来,应该把这一类归为分配排序,由于分配排序的一些缺陷,主要是时间代价很差,改进成为桶式排序(bucket sort),而桶排 ...
- apicloud教程1 (转载)
非常感谢APICloud官方给我版主职位,每天都看到很多朋友提出很多问题,我就借此机会写了一系列的教程,帮助大家从小白到高手之路.系列名称:<APICloud之小白图解教程系列>,会不定时 ...
- jave学习1--基础介绍
java 技术主要分为三个部分: jave SE基础知识. 对于各个程序的开发语言都包含的基本数据类型,循环控制,数组,方法等. jave SE的面向对象部分. 所有的面向对象的概念,为最终的接口准备 ...
- HDU2066一个人的旅行/最短路问题
一个人的旅行 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- libMobileGestalt与UDID
libMobileGestalt与UDID 没有评论 在iOS中,libMobileGestalt动态库, 用来取得各种系统变量,比如UDID, 磁盘使用量, 设备版本 在iOS7中,对于开发者来说, ...
- AutoTile 自动拼接(五) 学习与实践
今天不讲 权值检索,考虑到后期 自动拼接 做出来 更好玩,操作更方便.所以 今天我 补充一节, 网格计算与操作. 具体就是这么个效果,和地图编辑器一样,不过图块还是没有自然的拼接,这个一定一定是 下一 ...
- 最短路径算法——Dijkstra算法
在路由选择算法中都要用到求最短路径算法.最出名的求最短路径算法有两个,即Bellman-Ford算法和Dijkstra算法.这两种算法的思路不同,但得出的结果是相同的. 下面只介绍Dijkstra算法 ...
- JS 新浪API获取IP归属地
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js 返回值数据格式:var remote_ip_info = {“ret”:1,” ...