内容简介:本文收集了我常用的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. iOS学习之懒加载

    懒加载——也称为延迟加载,即在需要的时候才加载(效率低,占用内存小).所谓懒加载,其实是重写getter方法. 注意:如果是懒加载的话则一定要注意先判断是否已经有了,如果没有那么再去进行实例化 使用懒 ...

  2. java中把字节数组转换为16进制字符串

    把字符串数组转换为16进制字符串 import java.security.MessageDigest; public class StringUtil { public StringUtil() { ...

  3. word2vec的艰难成长史

    1.首先在网站上面下载gensim,我是在11服务器上面下载的 2.使用winpython打开 3.在command windows 下使用pip install gensim这句话进行,原先使用这句 ...

  4. 这样就算会了PHP么?-7

    循环之类的例子 <script language="javascript"> function calculate(a, b) { return a * b; } do ...

  5. OpenUrl 的跨平台实现

    OpenUrl 是 iOS 中 UIApplication 提供的一个函数,用于调用其它程序.实际上各个平台都有自己的实现,这里提供一个直接封装完的跨平台版本给大家.           Delphi ...

  6. joomla安装插件报错:上传文件到服务器发生了一个错误。 过小的PHP文件上传尺寸

    在安装joomla的AKeeba插件的时候报错如下:上传文件到服务器发生了一个错误. 过小的PHP文件上传尺寸.解决方法是修改php.ini文件,打开文件后搜索upload_max_filesize! ...

  7. 【剑指offer】面试题38:数字在排序数组中出现的次数

    题目: 统计一个数字在排序数组中出现的次数. 思路: 对二分查找进行改进,找到数字在数组中第一次出现和最后一次出现的位置,这样就得到它出现的次数. 以找第一次出现的位置为例:如果mid元素大于k,则在 ...

  8. WPF - Build Error总结

    1. are you missing an assembly reference 给项目添加新控件的时候,经常发现这种错误 Error 21 The type or namespace name 'C ...

  9. java 读取mysql库表数据

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import ...

  10. [2011山东省第二届ACM大学生程序设计竞赛]——Identifiers

    Identifiers Time Limit: 1000MS Memory limit: 65536K 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?act ...