美文网首页WEB前端程序开发
CSS之(font&background )属性简写

CSS之(font&background )属性简写

作者: 无脚鸟30 | 来源:发表于2019-03-27 10:44 被阅读1次

font 简写属性在一个声明中设置所有字体属性

字体属性主要包括下面几个

font-style(字体样式):normal(正常)、italic(斜体)、oblique(倾斜);

font-variant (字体变化): normal(正常)、small-caps(小体大写字母);

font-weight (字体粗细):normal(正常)、bold(加粗)。有些浏览器甚至支持采用100到900之间的数字(以百为单位);

font-size(字体大小):可通过多种不同单位(比如像素或百分比等)来设置, 如:12px,12pt,120%,1em;

font-family(字体类型):“Arial”、“Times New Roman”等;

如果用 font 属性的话,就可以把几个样式进行简化,减少书写的情况;font 属性的值应按以下次序书写(各个属性之间用空格隔开):

font:font-style | font-variant | font-weight | font-size/line-height | font-family


background 简写属性在一个声明中设置所有背景属性

在CSS2.1里,background属性的简写方式包含五种属性值,从CSS3开始,又增加了3个新的属性值,加起来一共8个。

background:  

[background-color]  背景颜色

[background-image]  背景图像

[background-repeat]  规定图像重复

[background-attachment]  规定滚动方式

[background-position] / [ background-size]  背景图像的定位和尺寸

[background-origin]  定位区域

[background-clip]  绘制区域


CSS2.1

background-color:使用的背景颜色。

background-image:使用的背景图像。

background-repeat:如何重复背景图像。

background-attachment:背景图像是否固定或者随着页面的其余部分滚动。

background-position:背景图像的位置。

CSS3

background-size:背景图片的尺寸。

background-origin:背景图片的定位区域。

background-clip:背景的绘制区域。

简写形式:

background: bg-color | bg-image | bg-repeat | bg-attachment | bg-position/bg-size | bg-origin | bg-clip;

background: bg-color  bg-image  bg-repeat  bg-position/bg-size  bg-origin  bg-clip  bg-attachment  initial | inherit;

需要注意的是里面的/,它和font以及border-radius里简写方式使用的/用法相似。/可以在支持这种写法的浏览器里在background-position后面接着写background-size。

相关文章

  • CSS之(font&background )属性简写

    font 简写属性在一个声明中设置所有字体属性 字体属性主要包括下面几个 font-style(字体样式):nor...

  • 学习笔记-CSS-2017.2.13

    一、CSS 背景 当使用简写属性时,属性值的顺序为:background-color; background-im...

  • web前端入门到实战:css常用样式背景background如何

    css背景background属性常用于定义HTML的背景,background简写属性作用是将背景属性设置在一个...

  • css中background简写属性

    在CSS2.1里,background属性的简写方式包含五种属性值,从CSS3开始,又增加了3个新的属性值,加起来...

  • 17-18日作业

    1.什么是css语法? 2.列举常见的css选择器? 3.background属性如何简写? 4.文本的属性有哪些...

  • 第二次作业

    1.什么是css语法? 2.列举常见的css选择器? 3.background属性如何简写? 4.文本的属性有哪些...

  • 任务九-主线

    CSS常见样式入门(下) 背景background: 简写属性,作用是将背景属性设置在一个声明中backgroun...

  • CSS的background简写方式

    在CSS2.1里,background属性的简写方式包含五种属性值,从CSS3开始,又增加了3个新的属性值,加起来...

  • CSS揭秘

    1.backgrouond简写 在background简写属性中指定background-sizing时,需要提供...

  • background系列属性

    background系列属性 background是一个简写属性,其属性值可以包括backgrund-colorb...

网友评论

    本文标题:CSS之(font&background )属性简写

    本文链接:https://www.haomeiwen.com/subject/yymavqtx.html