css属性简写集合
作为一个前端攻城狮,CSS那绝对是基础,可是基础也有掌握不牢的时候。今天就来总结一下容易写错的CSS属性简写问题。
1、background
背景颜色:background-color 基本语法:background-color : transparent | color
背景图像:background-image 基本语法:background-image : none | url ( url )
背景图像铺排:background-repeat 基本语法:background-repeat : repeat | no-repeat | repeat-x | repeat-y
背景图像滚动还是固定:background-attachment 基本语法:background-attachment : scroll | fixed
背景图像位置:background-position 基本语法:background-position : length || length或 background-position : position || position
length : 百分数 | 由浮点数字和单位标识符组成的长度值。请参阅 长度单位
position : top | center | bottom | left | center | right
以上是经常用到的background属性,大家一般都很熟悉,
其简写方式为:background : background-color || background-image || background-repeat || background-attachment || background-position
可是随着css的发展CSS3中又引入了其他4个属性:
背景的裁剪区域:background-clip 基本语法:background-clip : border-box | padding-box | content-box | no-clip
border-box:从border区域向外裁剪背景。
padding-box:从padding区域向外裁剪背景。
content-box:从content区域向外裁剪背景。
no-clip:从border区域向外裁剪背景。
背景显示区域:background-origin 基本语法:background-origin : border | padding | content
设置背景图片大小:background-size 基本语法:background-size :[ <length> | <percentage> | auto ]{1,2} | cover | contain
多重背景background : [background-image] | [background-origin] | [background-clip] | [background-repeat] | [background-size] | [background-position]
例如:background: url(img/multiple-backgrounds.png) left top no-repeat, url(img/multiple-backgrounds.png) -320px bottom no-repeat, url(img/multiple-backgrounds.png) -640px top repeat-y;
终于完了!这么多属性怎么简写呢?
查了好多资料终于找到了,好东西就该拿出来分享:
其简写方式为:background: background-color||background-image||background-repeat||background-attachment||background-position / background-size||background-origin||background-clip;
注意里面的反斜杠,它更font
和border-radius里简写方式使用的反斜杠的用法相似。主要是区别background-position和background-size
例如:background: url(images/1.jpg) no-repeat scroll center center / 50% content-box content-box red ;
或者:background: url(images/1.jpg) 0 0/20px 20px no-repeat,url(images/2.jpg) 50% 50%/contain no-repeat content-box green;
2、font
字体样式:font-style 基本语法:font-style : normal | italic | oblique
设置文本是否为小型的大写字母:font-variant 基本语法:font-variant : normal | small-caps
设置字体的粗细: font-weight 基本语法:font-weight : normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
设置字体尺寸 :font-size 基本语法:font-size : xx-small | x-small | small | medium | large | x-large | xx-large | larger |smaller | length
设置文本的字体名称序列: font-family 基本语法:font-family : ncursive | fantasy | monospace | serif | sans-serif
其简写方式为:font-style || font-variant || font-weight || font-size /line-height || font-family
例如:font:italic small-caps bold 12px/1.5em arial,verdana;
3、margin & padding 以margin为例,padding相同
其简写方式为:margin:margin-top margin-right margin-bottom margin-left;
例如:margin:1px 1px 1px 1px;
4、border
边框宽度:border-weight 基本语法:border-width : medium | thin | thick | length
边框样式:border-style 基本语法:border-style : none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
边框颜色: border-color 基本语法:border-width :color
其简写方式为:border : border-width || border-style || border-color
例如:border:1px solid #000;
5、outline
outline类似border,不同的是border会影响盒模型,而outline不会。
其简写方式为:outline : outline-color || outline-style || outline-width || outline-offset
例如:outline:red solid 1px; outline-offset:15px;
6、border-radius
右上角半径:border-top-right-radius ,
右下角半径:border-bottom-right-radius ,
左下角半径:border-bottom-left-radius ,
左上角半径:border-top-left-radius
当各个圆角半径相同时其简写方式为:border-radius :border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-top-left-radius;
例如:border-radius:0 6px 6px 6px;一般简写为 border-radius:0 6px 6px;
当各个圆角半径不同时其简写方式为:border-radius : none | <length>{1,4} [ / <length>{1,4} ]?
例如:border-radius:0px 5px 10px 15px/20px 15px 10px 5px;按照上有下左的规律依次写出每个角的两条边的半径
7、color的简写就不说了,太简单了
不知道总结的好不好,若有错烦指出,谢谢!
css属性简写集合的更多相关文章
- CSS属性简写
盒模型简写: 如果top.right.bottom.left的值相同,如下面代码:margin:10px 10px 10px 10px; 缩写为:margin:10px; 如果top和bottom值相 ...
- css的简写规范
css简写有这么几个好处,第一个也是最大的好处就是减少了代码的数量.第二个就是方便自己的编写吧. 下面来介绍几个常见的css属性简写规则. 一.字体(font) font-style:设置字体的样式. ...
- css属性大全(基础篇)
什么是CSS? CSS全称为Cascading Style Sheets,中文翻译为“层叠样式表”,简称CSS样式表,所以称之为层叠样式表(Cascading Stylesheet)简称CSS.在 ...
- css shorthand属性简写
一.什么是shorthand 属性简写(shorthand)就是一次性声明一组相关的属性.好处呢当然是众所周知的,让css从臃肿无序升级为简洁有效具有高可读性. 大多数的人都使用属性简写,我也用,但是 ...
- CSS 背景图像 background属性简写
background属性简写 background属性可以像margin padding属性一样,有简写方法,它的简写顺序是: background-color background-image ba ...
- HTML常用的css属性(及其简写)
这篇文章主要介绍几个常用css属性和简写 本文目录: 1.背景属性 2.边框属性 3.字体属性 4.外边距 5.填充 6.颜色 1.background[背景属性] background-color ...
- CSS属性(常用的属性)
CSS属性(常用的属性)http://www.w3school.com.cn/cssref/index.asp 一:文本与字体属性 1.字体属性 (1):font-size:字体的大小(例如:font ...
- jQuery修改操作css属性实现方法
在jquery中我们要动态的修改css属性我们只要使用css()方法就可以实现了,下面我来给各位同学详细介绍介绍. css()方法在使用上具有多样性,我们先来了解css()方法基本知识. css() ...
- CSS属性一览
CSS 属性 CSS 属性组: 动画 背景 边框和轮廓 盒(框) 颜色 内容分页媒体 定位 可伸缩框 字体 生成内容 网格 超链接 行框 列表 外边距 Marquee 多列 内边距 分页媒体 定位 打 ...
随机推荐
- 5)Java部分常用package功能介绍
1> java.lang (package) 这个是系统的基础类,比如String等都是这里面的,这个package是唯一一个可以不用import就可以使用的Package 包中关键类 ...
- spring mvc中的文件上传
使用commons-fileupload上传文件所需要的架包有:commons-fileupload 和common-io两个架包支持,可以到Apache官网下砸. 在配置文件spring-mvc.x ...
- 【代码】ini 文件读取工具类
using System; using System.Runtime.InteropServices; using System.Text; namespace hrattendance.Common ...
- Oracle并行事务回滚相关参数及视图
/******相关参数****/fast_start_parallel_rollback1.取值有3种:false,low,high2.各值含义:false ---禁用并行回滚功能 ...
- 10-排序5 PAT Judge
用了冒泡和插入排序 果然没有什么本质区别..都是运行超时 用库函数sort也超时 The ranklist of PAT is generated from the status list, whic ...
- CK表达式编辑器
1. 什么是表达式编辑器? 这个工具允许技术员传入一系列的参数,由用户编辑一个公式返回一种特定的结果.之所以需要使用表达式编辑器,就是因为用户编辑的公式经常变,技术员无法想出一办法来适应用户 ...
- Percona-Xtrabackup 2.3.3 死锁不再堵塞备份(二)
在percona-xtrabackup2.1.9下备份: session one:root(yoon)> show tables;+----------------+| Tables_in_yo ...
- C# ArrayList的用法总结
C# ArrayList的用法总结 System.Collections.ArrayList类是一个特殊的数组.通过添加和删除元素,就可以动态改变数组的长度. 一.优点 1. 支持自动改变大小的功能 ...
- Windows Phone8.1 SDK中的新控件
前言 WP8.1对开发者的影响要远大于对用户的影响.这篇博客就来一起看看哪些WP8.0中的控件被移除或替换,这些控件的介绍在MSDN上都非常的详细,所以这里只给出一些简单的介绍,来对比8.1 ...
- Java之XStream之下划线问题
XStream将Java对象序列为XML, 如果对象属性带有下划线,输出到XML时会转成"__"双下划. 网上很多资料说是Bug, XStream开发的大神没有哪么笨吧? 查了一下 ...