顶级经典常用的CSS属性收集整理

  文本两端对齐:

  

复制代码 代码如下:

  text-align:justify;

  text-justify:inter-ideograph;

  清除浮动:

  

复制代码 代码如下:

  .clear{clear:both;line-height:0;height:0;font-size:0;}

  清除浮动伪类:

  

复制代码 代码如下:

  .clearfix:after{content: ".";display: block;height: 0;clear: both;visibility: hidden;}

  设置不让单词断开

  

复制代码 代码如下:

  word-break : keep-all

  字符自动换行

  

复制代码 代码如下:

  word-break:keep-all;word-break:break-all;word-wrap:break-word

  使用 line-height 垂直居中

  

复制代码 代码如下:

  line-height:24px;/*使用固定宽度的容器并且需要一行垂直居中时,使用 line-height 即可(高度与父层容器一致),更多的垂直居中总结可以看这里。

  */

  清除容器浮动

  

复制代码 代码如下:

  #main {overflow:hidden;}

  不让链接折行

  

复制代码 代码如下:

  a {white-space:nowrap;}

  始终让 Firefox 显示滚动条

  

复制代码 代码如下:

  html {overflow:-moz-scrollbars-vertical;}

  使块元素水平居中

  

复制代码 代码如下:

  body, html {min-height:101%;}或者margin:0 auto;

  隐藏 Exploer textarea 的滚动条

  

复制代码 代码如下:

  textarea {overflow:auto;}

  设置打印分页

  

复制代码 代码如下:

  h2 {page-break-before:always;}/*设置打印网页时的分页*/

  删除链接上的虚线框

  

复制代码 代码如下:

  a,area { blr:e­xpression(this.onFocus=this.blur()) }

  :focus { -moz-outline-style: none; }

  最简单的 CSS 重置

  

复制代码 代码如下:

  * {margin: 0; padding: 0}/*此属性慎用,虽然能消除默认属性,但是对浏览器渲染有影响,而且在语义化表达上也欠佳。*/

  图片回车后打文字需要属性

  

复制代码 代码如下:

  img{vertical-align:top;}

  透明属性

  

复制代码 代码如下:

  filter:alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5;

  cursor:hand;

  鼠标换成手的形状

  

复制代码 代码如下:

  cursor:hand;