常用CSS缩写语法总结

news/2024/7/8 16:26:47 标签: css, border, fonts, url, image, scroll
 

使用缩写可以帮助减少你CSS文件的大小,更加容易阅读。css缩写的主要规则如下:

颜色

16进制的色彩值,如果每两位的值相同,可以缩写一半,例如:
#000000可以缩写为#000;#336699可以缩写为#369;

盒尺寸

通常有下面四种书写方法:

  • property:value1; 表示所有边都是一个值value1;
  • property:value1 value2; 表示top和bottom的值是value1,right和left的值是value2
  • property:value1 value2 value3; 表示top的值是value1,right和left的值是value2,bottom的值是value3
  • property:value1 value2 value3 value4; 四个值依次表示top,right,bottom,left

方便的记忆方法是顺时针,上右下左。具体应用在margin和padding的例子如下:
margin:1em 0 2em 0.5em;

边框(border)

边框的属性如下:

可以缩写为一句:border:1px solid #000;

语法是border:width style color;

背景(Backgrounds)

背景的属性如下:

  • background-color:#f00;
  • background-image:url(background.gif);
  • background-repeat:no-repeat;
  • background-attachment:fixed;
  • background-position:0 0;

可以缩写为一句:background:#f00 url(background.gif) no-repeat fixed 0 0;

语法是background:color image repeat attachment position;

你可以省略其中一个或多个属性值,如果省略,该属性值将用浏览器默认值,默认值为:

  • color: transparent
  • image: none
  • repeat: repeat
  • attachment: scroll
  • position: 0% 0%

字体(fonts)

字体的属性如下:

  • font-style:italic;
  • font-variant:small-caps;
  • font-weight:bold;
  • font-size:1em;
  • line-height:140%;
  • font-family:"Lucida Grande",sans-serif;

可以缩写为一句:font:italic small-caps bold 1em/140% "Lucida Grande",sans-serif;

注意,如果你缩写字体定义,至少要定义font-size和font-family两个值。

列表(lists)

取消默认的圆点和序号可以这样写list-style:none;,

list的属性如下:

  • list-style-type:square;
  • list-style-position:inside;
  • list-style-image:url(image.gif);

可以缩写为一句:list-style:square inside url(image.gif);


http://www.niftyadmin.cn/n/590236.html

相关文章

Linux chmod命令 修改文件权限被禁止 Exit code 126 from SFTP

在阿里云主机上搭建的LAMP环境,在修改相关文件config.cache.inc.php的属性的时候chmod 777 config.cache.inc.phpchmod: changing permissions of config.cache.inc.php: Operation not permitted 但是报了上面的一个错误费了一番周折,终于查到用 chattr…

10月10日热点故事精选 - 金山上市受追捧得益于“网游+软件”?

<iframe align"center" marginwidth"0" marginheight"0" src"http://www.zealware.com/csdnblog.html" frameborder"0" width"728" scrolling"no" height"90"></iframe>1 安装1.…

UniRx - Unity响应式编程插件

https://blog.csdn.net/zhenghongzhi6/article/details/79229585

C#封装:关于字段属性的get和set方法的小总结

https://blog.csdn.net/hikari10086/article/details/52775848

Linux下的chattr和lsattr命令

Linux下的chattr和lsattr命令 文件的隐藏属性 在Linux下我们可以用stat命令查看文件的相关属性信息&#xff0c;除了这些属性之外&#xff0c;Linux下的文件还有一些隐藏的属性&#xff0c;我们可以用lsattr命令来查看&#xff1a; $ lsattr mybook -----a-------e-- mybook 12…

C#中的var类型

https://blog.csdn.net/allenjy123/article/details/7228964

eclipse和maven生成web项目的war包的操作方法

一、eclipse中&#xff0c;在需要打包的项目名上右击&#xff0c;然后把鼠标光标指向弹出框中的“run as”&#xff1a; 二、之后会看到在这个弹出框的右侧会出现一个悬浮窗&#xff0c;如下&#xff1a; 三、在上边的第二个悬浮窗鼠标点击“maven clean”&#xff0c;maven会…

unity如何搜索所有场景

https://blog.csdn.net/alayeshi/article/details/52505228