内容简介:本文收集了我常用的CSS代码片段!
*reset
1 | body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, form, textarea { margin: 0; }body { font-family: arial, \5b8b\4f53; font-size: 12px; line-height: 1.5; }h1, h2, h3, h4, h5, h6, input, textarea, section { font-size: 100%; }input, textarea, section { font-family: inherit; }ul, ol { padding-left: 0; list-style-type: none; }table{ border-collapse:collapse; border-spacing:0; }th, td { padding: 0; }em,th, var {font-style:normal;}img { border: 0 none; vertical-align:top; }a { text-decoration:none; }a:hover{text-decoration:underline; }
|
Copier après la connexion
1 | .ipt { border: 1px solid #469021; background: #64A246; color: #fff; font:bold 11px arial,sans-serif; padding: 0.25em 0.5em; text-transform: uppercase; margin: 0; overflow: visible; height: 27px; line-height: 19px; _line-height: 16px; width: 80px;}
|
Copier après la connexion
*css圆角
1 | .radius { -moz-border-radius: 30px; -webkit-border-radius: 30px; border-radius: 30px;}
|
Copier après la connexion
*水平翻转
1 | .flipx { -moz-transform:scaleX(-1); -webkit-transform:scaleX(-1); -o-transform:scaleX(-1); transform:scaleX(-1); filter:FlipH();}
|
Copier après la connexion
*垂直翻转
1 | .flipy { -moz-transform:scaleY(-1); -webkit-transform:scaleY(-1); -o-transform:scaleY(-1); transform:scaleY(-1); filter:FlipV();}
|
Copier après la connexion
*css旋转
1 | .rotate90 { filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -webkit-transform: rotate(90deg); transform: rotate(90deg);}
|
Copier après la connexion
*css盒阴影
1 | .box_shadow { -moz-box-shadow: 3px 3px 4px #000; -webkit-box-shadow: 3px 3px 4px #000; box-shadow: 3px 3px 4px #000; filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=3px, OffY=3px, Color= '#000' ); -ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=3px, OffY=3px, Color='#000')" ;}
|
Copier après la connexion
*clearfix清浮动
1 | .clearfix:before, .clearfix:after { content: "" ; display:table; }.clearfix:after{ clear:both; }.clearfix{ *zoom:1;}
|
Copier après la connexion
*锚点
1 | <a name= "link" >不能为空</a><a href= "#link" >锚点链接</a>
|
Copier après la connexion
*纯CSS三角形
1 | .triangle { width: 0; height: 0; font-size: 0; line-height: 0; border-width: 50px; border-style: solid; border-top-color: #fff; border-right-color: #fff; border-bottom-color: red; border-left-color: #fff;}
|
Copier après la connexion
*opacity透明
1 | .opacity { filter: alpha(opacity=50); -khtml-opacity: 0.5; -moz-opacity: 0.5; opacity: 0.5;}
|
Copier après la connexion
*选择文本颜色
1 | ::selection { background: #e2eae2; }::-moz-selection { background: #e2eae2; }::-webkit-selection { background: #e2eae2; }
|
Copier après la connexion
*全屏背景
1 | .cover { background: url( 'bg.jpg' ) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;}
|
Copier après la connexion
*强制滚动条
Copier après la connexion
*渐变gradient
1 | .gradient { background: #629721; background-image: -webkit-gradient(linear, left top, left bottom, from(#83b842), to(#629721)); background-image: -webkit-linear-gradient(top, #83b842, #629721); background-image: -moz-linear-gradient(top, #83b842, #629721); background-image: -ms-linear-gradient(top, #83b842, #629721); background-image: -o-linear-gradient(top, #83b842, #629721); background-image: linear-gradient(top, #83b842, #629721);}
|
Copier après la connexion
*font-face
1 | @font-face { font-family: 'MyWebFont' ; src: url( 'webfont.eot' ); src: url( 'webfont.eot?#iefix' ) format( 'embedded-opentype' ), url( 'webfont.woff' ) format( 'woff' ), url( 'webfont.ttf' ) format( 'truetype' ), url( 'webfont.svg#svgFontName' ) format( 'svg' ); }body { font-family: 'MyWebFont' , Arial, sans-serif;}
|
Copier après la connexion
*png透明
1 | .png { width:200px; height:100px; background: url(this.png) no-repeat; _background:none; _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src= 'this.png' ,sizingMethod= 'crop' ); }
|
Copier après la connexion
*min-height
1 | .minheight { min-height: 550px; height: auto !important; height: 550px;}
|
Copier après la connexion