总结css常用的样式

会持续更新:

1、强制文本换行

div {
word-break: break-all;
word-wrap:break-word;
white-space: normal;
}
2、input更改placeholder颜色
/* WebKit browsers */
input::-webkit-input-placeholder { 
    color: #c7c7c7c;
}
/* Mozilla Firefox 4 to 18 */
input:-moz-placeholder { 
    color: #c7c7c7c;
}
/* Mozilla Firefox 19+ */
input::-moz-placeholder { 
    color: #c7c7c7c;
}
/* Internet Explorer 10+ */
input:-ms-input-placeholder { 
    color: #c7c7c7c;
}

3、屏幕背景撑满

.bg{
    position: relative;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    z-index: -1;
    background: #fff url(../images/bg.jpg) top center no-repeat;
    background-size: cover;
    -moz-background-size: cover;
    -webkit-background-size: cover;
    -o-background-size: cover;
}

4、单个图片居于垂直平行居中

.scroll-content { // 外部div
	width: 100%;
	height: 500px;
	display: -webkit-box;
	-webkit-box-pack: center;
	-webkit-box-align: center;
	background-color: #ccc;
}
.view_img { // 内部图片
	display: block;
	max-width: 100%;
	max-height: 100%;
	margin: auto;
	vertical-align: middle;
}

5、禁止iOS手机端自动识别复制黏贴功能
a{
    -webkit-user-select: none; / disable selection/Copy of UIWebView /
    -webkit-touch-callout: none; / disable the IOS popup when long-press on a link /
}
6、伪类更改input选择背景图片
.input_checked::before{
    position: absolute;
    background-image: url(images/icon1.png);
    display: block;
    content: '';
    width: 15px;
    height: 15px;
}
.input_checked:checked::before {
    background-image: url(images/icon2.png);
}
7、清除li浮动撑不开ul的问题(<ul class="clearfix">...</ul>)

.clearfix:before, .clearfix:after {
    content:"";
    display:table;
}
.clearfix:after {
    clear: both;
}
.clearfix {
    zoom: 1;
}
8、等比例缩放图片
.div{
     width: x %;  图片占整个宽度的比例
     max-width: y px;   一倍图的宽度
     display: block;
}
9、背景渐变
body{
background-color: #f8e71c;  // Old browsers 
background-image: -moz-linear-gradient(top,#f8e71c 0%,  #fad961 100%);  //FF3.6+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8e71c), color-stop(100%,#fad961));  // Chrome,Safari4+
background-image: -webkit-linear-gradient(top,#f8e71c 0%,  #fad961 100%);  // Chrome10+,Safari5.1+
background-image: -o-linear-gradient(top,#f8e71c 0%, #fad961 100%);  // Opera 11.10+ 
background-image: -ms-linear-gradient(top,#f8e71c 0%, #fad961 100%);  // IE10+
background-image: linear-gradient(to bottom,#f8e71c 0%,#fad961 100%);   // W3C
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8e71c', endColorstr='#fad961',GradientType=0 );  // IE6-8 
}
10、手机端(iOS/Android)比较能接受的默认字体
.body-md{
  font-family: Roboto, "Helvetica Neue", sans-serif;
}
.body-ios{
  font-family: -apple-system, "Helvetica Neue", "Roboto", sans-serif;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值