内容简介:本文收集了我常用的CSS代码片段!

*reset

@charset "utf-8";

/* reset */
body, dl, dd, h1, h2, h3, h4, h5, h6, p, form, ol, ul, textarea, button, input, select {
margin:;
}
ol, ul, dd, td, th, textarea, button, input, select {
padding:;
}
h1, h2, h3, h4, h5, h6 {
font-size: 100%;
font-weight:;
}
body {
font: 12px/1.5 "Microsoft Yahei", SimSun, arial, sans-serif;
}
ol, ul {
list-style: none;
}
a, button, input, textarea, select {
outline:;
color: inherit;
font: inherit;
}
button::-moz-focus-inner, input::-moz-focus-inner {
border:;
padding:;
}
button {
overflow: visible;
}
button, input[type="button"], input[type="reset"], input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
input::-moz-placeholder, textarea::-moz-placeholder {
color: #ccc;
}
input:-ms-input-placeholder, textarea:-ms-input-placeholder {
color: #ccc;
}
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
color: #ccc;
}
input::-ms-clear {
display: none;
}
a {
text-decoration: none;
}
img {
vertical-align: top;
border: 0 none;
}
textarea {
resize: none;
overflow: auto;
}
table {
border-collapse: collapse;
border-spacing:;
}
th {
text-align: center;
}
/* clearfix */
.clearfix:before, .clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom:;
}

*select兼容

select { height:22px; line-height:18px; padding:2px 0; }

*input兼容

.ipt {
border: 1px solid #469021;
background: #64A246;
color: #fff;
font:bold 11px arial,sans-serif;
padding: 0.25em 0.5em;
text-transform: uppercase;
margin:;
overflow: visible;
height: 27px;
line-height: 19px;
_line-height: 16px;
width: 80px;
}

*css圆角

.radius {
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
border-radius: 30px;
}

*水平翻转

.flipx {
-moz-transform:scaleX(-1);
-webkit-transform:scaleX(-1);
-o-transform:scaleX(-1);
transform:scaleX(-1);
filter:FlipH();
}

*垂直翻转

.flipy {
-moz-transform:scaleY(-1);
-webkit-transform:scaleY(-1);
-o-transform:scaleY(-1);
transform:scaleY(-1);
filter:FlipV();
}

*css旋转

.rotate90 {
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}

*css盒阴影

.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')";
}

*clearfix清浮动

.clearfix:before, .clearfix:after { content:""; display:table; }
.clearfix:after{ clear:both; }
.clearfix{ *zoom:;}

*锚点

<a name="link">不能为空</a>
<a href="#link">锚点链接</a>

*纯CSS三角形

.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;
}

*opacity透明

/*opacity*/
.opacity {
filter: alpha(opacity=50);
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
opacity: 0.5;
}

*选择文本颜色

/* 自定义文本选择颜色 */
::selection { background: #e2eae2; }
::-moz-selection { background: #e2eae2; }
::-webkit-selection { background: #e2eae2; }

*全屏背景

/* 全屏背景 */
.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;
}

*强制滚动条

html { height: 101% }

*渐变gradient

/* 渐变 */
.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);
}

*font-face

/*font-face*/
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
body {
font-family: 'MyWebFont', Arial, sans-serif;
}

*png透明

/* png透明 */
.png {
width:200px;
height:100px;
background: url(this.png) no-repeat;
_background:none;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='this.png',sizingMethod='crop');/* 路径相对于html */
}

*min-height

/* 最小高度 */
.minheight {
min-height: 550px;
height: auto !important;
height: 550px;
}

*移动端reset 

body,nav,dl,dt,dd,p,h1,h2,h3,h4,ul,ol,li,input,button,textarea,footer{margin:;padding:}
header,nav,section,article,footer,figure,figcaption { display: block; }
html,body{width:100%;height:100%;}
li{list-style:none;}
h1,h2,h3,h4,h5{font-size:100%}
img,object,video,embed { max-width: 100%;}
img {border:none; vertical-align: middle; }
button,input,select,textarea{font-size:100%; vertical-align:middle; outline:none;}
a { text-decoration: none; }
body{min-width:320px;font:normal 62.5%/1.5 Tahoma,"Lucida Grande",Verdana,"Microsoft Yahei",STXihei,hei;color:#000;background:#f1f1f1;overflow-x:hidden;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-text-size-adjust:none;-moz-user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);}
/* common */
.g-tensile { width: 100%; height: 100%; }
.g-auto { margin-left: auto; margin-right: auto; }

HTML/CSS代码片段的更多相关文章

  1. 30+有用的CSS代码片段

    在一篇文章中收集所有的CSS代码片段几乎是不可能的事情,但是我们这里列出了一些相对于其他的更有用的代码片段,不要被这些代码的长度所吓到,因为它们都很容易实现,并且具有良好的文档.除了那些解决常见的恼人 ...

  2. 【转】30+有用的CSS代码片段

    来自:WEB资源网 链接:http://webres.wang/31-css-code-snippets-to-make-you-a-better-coder/ 原文:http://www.desig ...

  3. 实用的60个CSS代码片段

    1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...

  4. 60个有用CSS代码片段

    1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...

  5. 拥有的50个CSS代码片段(上)

    1. CSS 重置 ;;;font-size: 100%; font: inherit; vertical-align: baseline; outline: none; -webkit-box-si ...

  6. (转)每位设计师都应该拥有的50个CSS代码片段

    原文地址:http://www.cnblogs.com/fengyuqing/archive/2013/06/15/css_50.html 面对每年如此多的 新趋势 ,保持行业的领先是个很困难问题. ...

  7. 很实用的50个CSS代码片段

    原文:50 Useful CSS Snippets Every Designer Should Have          面对每年如此多的 新趋势 ,保持行业的率先是个非常困难问题. 站点设计者和前 ...

  8. Css学习总结(2)——60个有用CSS代码片段

    1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...

  9. 实用的60个CSS代码片段[上]

    1.垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,可以很优雅的解决这个困惑: .verticalcenter{ position: re ...

随机推荐

  1. 关于ubuntu 系统

    1. ubuntu怎么卸载自带的软件中心?sudo apt-get remove software-center 2. 重新安装ubuntu软件中心!sudo apt-get install --re ...

  2. C程序设计语言练习题1-1

    练习1-1 在你自己的系统中运行"hello, world"程序.再有意去掉程序中的部分内容,看看会得到什么出错信息. 代码如下: #include <stdio.h> ...

  3. Linux_access the file or directory which start with "-"

    cd -- filename/dirName [ccmobil@vm-a65a-fc19 wstemp]$ cd -/ -bash: cd: -: invalid option cd: usage: ...

  4. 破解官方recovery的签名验证

    步骤简述1.解包recovery.img,2.反编译/sbin/recovery,用ida64plus3.在反编译出来的文本中查找:signature 4.简单的看一下指令流程,CBZ下面是faile ...

  5. [每日一题JS] 正则表达式

    判断字符串是否是这样组成的,第一个必须是字母,后面可以是字母.数字.下划线,总长度为5-20 var reg = /\b[a-zA-Z]{1}[a-zA-Z0-9_]{4,19}\b/; var fl ...

  6. Expression构建DataTable to Entity 映射委托

    namespace Echofool.Utility.Common { using System; using System.Collections.Generic; using System.Dat ...

  7. python编程之字符串转处理

    比如255的16进制是FF. 转换成整型就是  int("FF",16)   console上输出就是255   int("FFFF",16)就是65535 如 ...

  8. Oracle 11gR2 RAC Votedisk and OCR Diskgroup Recovery

    check votedisk and OCR [root@vzwc1 ~]# ocrcheck Status of Oracle Cluster Registry is as follows : Ve ...

  9. How to run Tomcat without root privileges? 常规用户使用tomcat的80端口

    How to run Tomcat without root privileges? 1. The best way is to use jsvc, available as part of the  ...

  10. Android: 在WebView中获取网页源码

    1. 使能javascript: ? 1 webView.getSettings().setJavaScriptEnabled(true); 2. 编写本地接口 ? 1 2 3 4 5 final c ...