CSS属性参考手册(一)

CSS属性

文字

属性描述属性值语法
color文字颜色颜色的名称、十六进制、RGB、RGBA(a 表示透明度:0=透明;1=不透明)、
HSL、HSLA(色相-饱和度-明度-阿尔法)
color:red(#FF0000);
rgba(255,0,0, 1)
hsla(240,100%,50%,1)
opacity元素透明度级别value不透明度,0.0(完全透明)到1.0(完全不透明)、inherit
direction文字书写方向ltr(文本方向从左到右)、rtl(从右到左)、inheritdirection:rtl;
font在一个声明中设置所有字体属性顺序如下:font-style、font-variant、font-weight、font-size/line-height、font-familyfont:15px arial,sans-serif;
font-style文字样式normal、italic(斜体)、oblique(倾斜)、inheritfont-style:itelic; //文字斜体
font-variant显示小型大写字母的字体normal、small-caps、inheritfont-variant:small-caps; //小字体
font-weight文字粗细(100-700)、normal(400)、bold(700)、bolder、lighterfont-weight:bold(400); //文字粗体
font-size文字大小(xx-small、x-small、small、medium、large、x-large、xx-large)、smaller、larger、length、%、inheritfont-size:12px;
line-height设置行高normal、number、length、%、inheritline-height:200%;
font-family文字字体family-name - 指定的系列名称:具体字体的名称(比如:times、courier、arial)
generic-family - 通常字体系列名称(比如:serif、sans-serif、cursive、fantasy、monospace)
font-family:宋体,sans-serif;
@font-face一个规则,允许网站下载并使用其他超过"Web- safe"字体的字体必需:font-family(name)、src(URL)
可选:font-stretch、font-style、font-weight、unicode-range
@font-face {
font-family: myFirstFont;
src: url(‘Sansation_Light.ttf’),
url(‘Sansation_Light.eot’); } //指定名为"myFirstFont"的字体,并指定在哪里可以找到它的URL
font-size-adjust为元素规定 aspect 值none、inherit、number{定义字体的 aspect 值比率。可使用的公式: 首选字体的字体尺寸 * (font-size-adjust 值 / 可用字体的 aspect 值)=可应用到可用字体的字体尺寸}font-size-adjust:0.58;
font-stretch文字收缩或拉伸wider(宽)、narrower(窄)、ultra-condensed、extra-condensed、condensed、semi-condensed(略微紧缩)、normal、semi-expanded、expanded(加宽)、extra-expanded、ultra-expanded、inheritfont-stretch:wider; //文本更宽
letter-spacing字间距离normal、length、inheritletter-spacing:2px;
vertical-align元素的垂直对齐方式baseline(默认)、sub(下标字)、super(上标字)、top(垂直向上对齐)、text-top(文字垂直向上对齐)、middle(垂直居中对齐)、bottom(垂直向下对齐)、text-bottom(文字垂直向下对齐)、length、%、inheritvertical-align:sub;
vertical-align:text-top;
text-align文字的水平对齐方式left(文字排列到左边)、right(排列到右边)、center(居中)、justify(两端对齐)、inherittext-align:center;
text-decoration文字的装饰效果none(默认)、underline(下划线)、overline(上划线)、line-through(删除线)、blink(闪烁的文字)、inherittext-decoration: underline overline dotted red; //红色虚线
text-decoration: underline overline wavy red; //红色波浪线
text-emphasis向元素的文字应用重点标记以及重点标记的前景色text-emphasis-style、text-emphasis-colortext-emphasis:filled blue;
text-indent文字块首行缩进length、%、inherittext-indent:50px;
text-align-last当 text-align 设置为 justify 时,最后一行的对齐方式auto、left(最后一行向左对齐)、right(向右对齐)、center(居中对齐)、justify(两端对齐)、start{最后一行在行开头对齐(如果 text-direction 是从左到右,则向左对齐;如果 text-direction 是从右到左,则向右对齐)}、end{最后一行在行末尾对齐(如果 text-direction 是从左到右,则向右对齐;如果 text-direction 是从右到左,则向左对齐)}、initial、inherittext-align-last {
text-align: justify;
text-align-last: right;
-moz-text-align-last: right; //针对 Firefox 的代码 }
text-justify当 text-align 设置为 justify 时指定分散对齐的方式auto(浏览器决定齐行算法)、none(禁用齐行)、inter-word (增加/减少单词间的间隔)、inter-ideograph (用表意文本来排齐内容)、inter-cluster、distribute、kashidatext-justify {
text-align:justify;
text-justify:inter-word; }
text-transform文字大小写none、capitalize(文本中的每个单词大写字母开头)、uppercase(仅有大写)、lowercase(仅有小写)、inherittext-transform:none;
text-outline文字轮廓必需:thickness(轮廓粗细)、color
可选:blur(轮廓模糊半径)
text-outline: 2px 2px #ff0000;
text-overflow文字溢出包含元素时发生的事情clip (修剪文本)、ellipsis(显示省略符号来代表被修剪的文本)、string(给定的字符串)text-overflow:ellipsis;
text-shadow文字阴影必需:h-shadow(水平阴影的位置)、v-shadow(垂直阴影的位置)
可选:blur(模糊的距离)、color(阴影的颜色)
text-shadow: h-shadow v-shadow blur color;
text-shadow: 5px 5px 5px #FF0000;
text-wrap文字换行normal(换行点换行)、none(不换行)、unrestricted(任意两个字符)、suppress(压缩元素)text-wrap:normal;
hanging-punctuation标点符号是否可能超出行框none(不放置)、first(首行)、last(结尾)、allow-end、force-endhanging-punctuation:first;
punctuation-trim标点符号是否要去掉none(请勿修剪打开或关闭标点符号)、start(开头)、end(末尾)、allow-end、adjacentpunctuation-trim:start;
white-space处理元素中的空白normal(默认)、pre(被保留,类似 HTML的<pre>)、nowrap(文本不换行,遇到 <br> 标签为止)、pre-wrap(保留,正常换行)、pre-line(合并,保留换行)、inheritwhite-space:pre-wrap;
word-spacing单词间距normal、length、inheritword-spacing:30px;
word-break非中日韩文字的换行normal、break-all(单词内换行)、keep-all(半角空格、连字符处换行)word-break:keep-all;
word-wrap浏览器是否对过长的单词进行换行normal(断字点换行)、break-word(长单词URL)word-wrap:break-word;

项目(列表)

属性描述属性值语法
list-style设置所有的列表属性顺序如下: list-style-type、list-style-position、list-style-imagelist-style:square inside url(“home.png”);
list-style-image图象设置为列表项标记URL(图像路径)、none(无图形)、inheritlist-style-image:url(“logo.png”);
list-style-position设置列表项标记的放置位置inside(标记在文本以内)、outside(默认值,标记文本左侧,标记在文本以外)、inherilist-style-position: inside;
属性描述属性值语法
list-style-type设置列表项标记的类型none(无标记)、disc(实心圆)、circle(空心圆)、square(实心方块)、decimal(数字)、decimal-leading-zero(0开头的数字01, 02, 03, 等)、lower-roman(小写罗马数字i, ii, iii,等)、upper-roman(大写罗马数字(I, II, III, 等)、lower-alpha(小写英文字母a, b, c, 等)、upper-alpha(大写英文字母A, B, C, 等)、lower-greek (小写希腊字母alpha, beta, gamma, 等)、lower-latin(小写拉丁字母a, b, c, 等)、upper-latin(大写拉丁字母A, B, C, 等)、hebrew(传统的希伯来编号)、armenian(传统的亚美尼亚编号)、georgian(传统的乔治亚编号方式an, ban, gan, 等)、cjk-ideographic(简单的表意数字)、hiragana(日文平假名字符)、katakana(日文片假名字符)、hiragana-iroha(日文平假名序号)、katakana-iroha(日文片假名序号)list-style-type:circle;
list-style-type:square;
list-style-type:upper-roman;
list-style-type:lower-alpha;

多列

属性描述属性值语法
columns简写,列宽和列数column-width、column-countcolumns:80px 4;
column-count元素列数number、autocolumn-count:3;
column-width列的宽度auto、lengthcolumn-width:100px;
column-fill填充列balance(列长短平衡)、auto(列顺序填充)column-fill:auto;
column-gap列之间差距length、normalcolumn-gap:30px;
column-rule简写,列之间的宽度,样式和颜色column-rule-width、column-rule-style、column-rule-colorcolumn-rule:3px outset #FF0000;
column-rule-color列之间的颜色colorcolumn-rule-color:#FF0000;
column-rule-style列之间的样式none、hidden(隐藏)、dotted(点状)、dashed(虚线)、solid(实线)、double(双线)、groove(3D grooved)、ridge(3D ridged)、inset(3D inset)、outset(3D outset)column-rule-style:outset;
column-rule-width列之间的宽度thin、medium、thick、lengthcolumn-rule-width:1px;
column-span元素跨越几列1、allcolumn-span:all;

背景

属性描述属性值语法
background复合属性,对象背景特性各值之间用空格分隔,不分先后顺序(background-color、background-position、background-size、background-repeat、background-origin、background-clip、background-attachment 和 background-image)background: #FF0000 url(“logo.png”) no-repeat fixed center;
background-attachment背景图像是否对象内容滚动,必须先指定background-image属性scroll(默认,背景图片随页面滚动而滚动)、fixed(固定)、local(随元素内容滚动而滚动)、initial、inheritbackground-image:url(“logo.png”);
background-attachment:fixed;
background-blend-mode背景层混合模式(图片与颜色)normal(默认,正常混合模式)、multiply(正片叠底)、screen(滤色)、overlay(叠加)、darken(变暗)、lighten(变亮)、color-dodge(颜色减淡)、saturation(饱和度)、color(颜色)、luminosity(亮度)background-image: linear-gradient(to right, white 0%,red 100%), url(“logo.png”);
background-blend-mode: lighten;
background-clip背景图像向外裁剪区域border-box(默认,背景被裁剪到边框盒)、padding-box(内边距框)、content-box(内容框)background-clip: padding-box;
background-color背景颜色color、transparent(透明)、inheritbackground-color:#FF0000;
background-image背景图像url(“URL”) 图像的路径、none不显示、linear-gradient()线性渐变的 “图像”(从上到下)、radial-gradient()用径向渐变创建 “图像”(center to edges)、repeating-linear-gradient()重复线性渐变 “图像”、repeating-radial-gradient()重复径向渐变 “图像”、inheritbackground-image:url(“logo.png”);
background-image: linear-gradient(red, green, blue);
background-image: radial-gradient(red, green, blue);
background-origin背景图像定位区域padding-box(背景图像相对于内边距框来定位)、border-box(边框盒)、content-box(内容框)background-origin:border-box;
background-position背景图像位置,必须先指定background-image属性(left top、left center、left bottom、right top、right center、right bottom、center top、center center、center bottom)、x% y%(水平,垂直)左上角0%0%,右下角100%100%、xpos ypos(水平,垂直)左上角是0,单位可以是像素(0px0px)、inheritbackground-image:url(“logo.png”);
background-position:center;
background-position:50% 50%;
background-position:100px 100px;
background-repeat是否重复背景图像,必须先指定background-image属性repeat(垂直和水平方向重复)、repeat-x(水平重复)、repeat-y(垂直重复)、no-repeat(background-image不重复)、inheritbackground-image:url(“logo.png”);
background-repeat:no-repeat;
background-size背景图像尺寸length(设置宽度,高度,只给一个值,第二个为 auto)、percentage(背景定位区域的百分比)、cover(覆盖背景)、contain(适合背景)background-size:50px 50px;

尺寸

属性描述属性值语法
height元素高度auto(默认)、length(px、cm 等单位定义高度)、%、inheritheight:100px;
max-height元素最大高度none(默认)、length、%、inheritmax-height:50px;
max-width元素最大宽度none(默认)、length、%、inheritmax-width:100px;
min-height元素最小高度length、%、inheritmin-height:50px;
min-width元素最小宽度length、%、inheritmin-height:50px;
width元素宽度auto(默认)、length(px、cm 等单位定义宽度)、%、inheritwidth:100px;

外边距

属性描述属性值语法
margin设置所有外边距auto、length(像素、厘米等,默认值是 0px)、%、inheritmargin:10px 5px 15px 20px; //上右下左
margin:10px 5px 15px; //上/右左/下
margin:10px 5px; //上下/右左
margin:10px;
margin-bottom下外边距auto、length、%、inheritmargin-bottom:2cm;
margin-left左外边距auto、length、%、inheritmargin-left:2cm;
margin-right右外边距auto、length、%、inheritmargin-right:6cm
margin-top上外边距auto、length、%、inheritmargin-top:2cm;

内边距

属性描述属性值语法
padding设置所有内边距length(像素、厘米等,默认值是 0px)、%、inheritpadding:10px 5px 15px 20px; //上右下左
padding:10px 5px 15px; //上/右左/下
padding:10px 5px; //上下/右左
padding:10px;
padding-bottom下内边距length、%、inheritpadding-bottom:3px;
padding-left左内边距length、%、inheritpadding-left:2cm;
padding-right右内边距length、%、inheritpadding-right:2cm;
padding-top上内边距length、%、inheritpadding-top:2cm;

边框

属性描述属性值语法
border复合属性,设置所有边框顺序如下:border-width、border-style、border-colorborder:3px solid red;
border-color边框颜色color、transparent(透明,默认)、inheritborder-color:red green blue pink; //上右下左
border-color:red green blue; //上/左右/下
border-color:red green; //上下/左右
border-color:red;
border-style边框样式none(无边框)、hidden(none 相同,应用于表)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritborder-style:dotted solid double dashed; //上右下左
border-style:double;
border-width边框宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritborder-width:thin medium thick 10px; //上右下左
border-width:5px;
border-bottom复合属性,设置所有底部边框顺序如下:border-bottom-width、 border-bottom-style、border-bottom-colorborder-bottom:thick dotted #FF0000;
border-bottom-color底部边框颜色color、transparent(透明,默认)、inheritborder-bottom-color:#FF0000;
border-bottom-style底部边框样式none(无边框)、hidden(none 相同,应用于表)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritborder-bottom-style:double;
border-bottom-width底部边框宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritborder-bottom-width:5px;
border-left复合属性,设置所有左边边框顺序如下:border-left-width、border-left-style、and border-left-colorborder-left:thick double #FF0000;
border-left-color左边边框颜色color、transparent(透明,默认)、inheritborder-left-color:#FF0000
border-left-style左边边框样式none(无边框)、hidden(none 相同,应用于表)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritborder-left-style:double;
border-left-width左边边框宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritborder-left-width:5px;
border-right复合属性,设置所有右边边框顺序如下:border-right-width、border-right-style、border-right-colorborder-right:thick double #FF0000;
border-right-color右边边框颜色color、transparent(透明,默认)、inheritborder-right-color:#FF0000
border-right-style右边边框样式none(无边框)、hidden(none 相同,应用于表)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritborder-right-style:double;
border-right-width右边边框宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritborder-right-width:5px;
border-top复合属性,设置所有顶部边框顺序如下:border-top-width、 border-top-style、border-top-colorborder-top:thick double #FF0000;
border-top-color顶部边框颜色color、transparent(透明,默认)、inheritborder-top-color:#FF0000;
border-top-style顶部边框样式none(无边框)、hidden(none 相同,应用于表)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritborder-top-style:double;
border-top-width顶部边框宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritborder-top-width:5px;
border-collapse表格边框是否被合并为一collapse(合并为一,忽略border-spacing、empty-cells)、separate(默认值,分开,不忽略border-spacing、empty-cells)、inheritborder-collapse:collapse;
border-image边框样式使用图像来填充border-image-source、border-image-slice、border-image-width、border-image-outset、border-image-repeatborder-image: url(logo.png) 30 stretch;
border-image-outset边框图像超过边框盒的量length(边框图像与边框border-image距离,默认为0)、number(代表border-width倍数)border-image-outset:5px 5px 5px 5px;
border-image-outset:0 1 2 1;
border-image-repeat图像边界stretch(默认,拉伸图像)、repeat(平铺)、round(缩放)、space(扩展)、initial、inheritborder-image-repeat: repeat;
border-image-slice图像边框的向内偏移number、%、fill(保留图像的中间部分)border-image-slice: 50% 50%;
border-image-source边框的图片none(无图像)、image(图像路径)border-image-source: url(logo.png);
border-image-width图像边框的宽度number、%、auto(指定宽度是image slice内在宽度或高度)border-image-width: 50 50;
border-radius圆角边框顺序如下:border-top-left-radius、border-top-right-radius、border-bottom-right-radius、border-bottom-left-radiusborder-radius:25px 5px 25px 5px;
border-radius:25px
border-bottom-left-radius左下角边框的形状length(弯道形状)、%(角落形状)border-bottom-left-radius:12px;
border-bottom-right-radius右下角边框的形状length、%border-bottom-right-radius:12px;
border-top-left-radius左上角边框的形状length、%border-top-left-radius:12px;
border-top-right-radius右上角边框的形状length、%border-top-right-radius:12px;
box-shadow添加阴影必需:h-shadow(水平阴影)、v-shadow(垂直阴影)
可选:blur(模糊距离)、spread(阴影大小)、color、inset(外层阴影改变阴影内侧阴影)
box-shadow: 10px 10px 5px #FF0000;
border-spacin单元格边框间的距离length length{px、cm 等单位,不允许使用负值,一个length(水平和垂直),两个 length(水平,垂直)}、inheritborder-spacing:10px 20px;
outline复合属性,外线条轮廓顺序如下:outline-color、 outline-style、outline-widthoutline:red outset 5px;
outline-color外线条轮廓颜色color、invert(默认,逆向颜色)、inheritoutline-color:#FF0000;
outline-style外线条轮廓样式none(无边框)、dotted(点状边框)、dashed(虚线)、solid(实线)、double(双线)、groove( 3D 凹槽边框)、ridge(3D 垄状边框)、inset(3D inset 边框)、outset(3D outset 边框)、inheritoutline-style:double;
outline-width外线条轮廓宽度thin(细边框)、medium(默认,中等边框)、thick(粗边框)、length(自定义)、inheritoutline-width:5px;

盒子

属性描述属性值语法
overflow-x内容溢出了区域,对左/右边缘裁剪visible(不裁剪)、hidden(裁剪,不提供滚动)、scroll(裁剪,滚动)、auto(溢出应该提供滚动)、no-display(内容不适合,删除框)、no-content(内容不适合,隐藏)overflow-x:scroll;
overflow-y内容溢出了区域,对上/下边缘裁剪visible(不裁剪)、hidden(裁剪,不提供滚动)、scroll(裁剪,滚动)、auto(溢出应该提供滚动)、no-display(内容不适合,删除框)、no-content(内容不适合,隐藏)overflow-y:scroll;
overflow-style溢出元素滚动auto、scrollbar(添加滚动条)、panner、move(移动内容)、marquee(内容自主移动)overflow-style:marquee,panner;
rotationrotation-point定义的点对元素旋转angle (元素旋转角度,值:0deg 到 360deg)rotation:180deg;
rotation-point距离上左边框边缘的偏移点left top、left center、left bottom、right top、right center、right bottom、center top、center center、center bottom、x% y%rotation-point:50% 50%;

过渡

属性描述属性值语法
transition简写,元素当过渡效果transition-property、transition-duration、transition-timing-function、transition-delaytransition: width 2s;
transition-property过渡的 CSS 属性none、all、property(CSS 属性名称列表)transition-property:width/height;
transition-duration过渡进行的时间长度time(秒或毫秒)transition-duration:4s;
transition-timing-function过渡进行的时序函数linear[相同速度开始至结束(cubic-bezier(0,0,1,1))]、ease[慢速开始变快,慢速结束(cubic-bezier(0.25,0.1,0.25,1))]、ease-in [慢速开始cubic-bezier(0.42,0,1,1)]、ease-out[慢速结束(cubic-bezier(0,0,0.58,1)]、ease-in-out[慢速开始和结束(cubic-bezier(0.42,0,0.58,1)]、cubic-bezier(n,n,n,n)值是 0 至 1 之间transition-timing-function:linear;
transition-delay过渡开始的时间所有元素::before和::after 伪元素、time(秒或毫秒)transition-delay:2s
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值