移动端开发常用CSS设置

基础版

/* 去掉按钮或链接点击的灰色背景 */
* {
	-webkit-tap-highlight-color: rgba(0,0,0,0) !important;
	tap-highlight-color: rgba(0,0,0,0) !important;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 4px;
    height: 2px;
}
::-webkit-scrollbar-track-piece {
    background-color: #ccc;
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:vertical {
    height: 15px;
    background-color: #999;
    border-radius: 2px;
    min-height: 65px;
}
::-webkit-scrollbar-thumb:horizontal {
    width: 15px;
    background-color: #999;
    border-radius: 2px;
    min-height: 65px;
}


/* 尺寸根据设备屏幕宽度等比缩放 */
html { font-size: 62.5%; }
@media only screen and (min-width: 481px) {
    html { font-size: 94%!important; }
}
@media only screen and (min-width: 561px) {
    html { font-size: 109%!important; }
}
@media only screen and (min-width: 641px) {
    html { font-size: 125%!important; }
}

body {
	-webkit-font-smoothing: antialiased; /* 字体抗锯齿渲染 */
    -webkit-text-size-adjust: none; /* 禁用iPhone中Safari的字号自动调整 */
    -webkit-user-select: none; /* 禁用用户选中页面内容 */    
	-webkit-overflow-scrolling: touch; /* 解决IOS默认滑动很卡的情况 */
	-webkit-touch-callout: none; /* 触摸或长按目标时禁止显示系统默认菜单 */
}

详尽版

/* base.css*/
* {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-tap-highlight-color: transparent;
}
*::after,
*::before {
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

html,
body,
div,
form,
p,
ul,
li,
span,
label,
img,
input {
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    position: relative;
    font-family: PingFang SC, Hiragino Sans GB, Arial, Microsoft YaHei, Verdana, Roboto, Noto, Helvetica Neue, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: none;
    word-break: break-all;
    overflow: auto;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}
ul,
li {
    list-style: none;
}

input,
textarea,
button {
    outline: none;
}
button[disabled] {
    opacity: 0.5;
}

input[type='text'] {
    -webkit-appearance: none; /* 去除文本框阴影 */
}
textarea {
    -webkit-appearance: none;
}

a {
    color: #00bcf0;
}
a,
a:hover {
    text-decoration: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.tl-f {
    table-layout: fixed;
}

/* 文字相关 */
.ta-l {
    text-align: left;
}
.ta-c {
    text-align: center;
}
.ta-r {
    text-align: right;
}
.fw-n {
    font-weight: normal;
}
.td-n {
    text-decoration: none;
}
.ws-nw {
    white-space: nowrap;
}

/* 垂直对齐方式 */
.va-t {
    vertical-align: top;
}
.va-m {
    vertical-align: middle;
}
.va-b {
    vertical-align: bottom;
}
.va-tt {
    vertical-align: text-top;
}
.va-tb {
    vertical-align: text-bottom;
}

/* 显示方式 */
.dn {
    display: none;
}
.db {
    display: block;
}
.di {
    display: inline;
}
.d-ib {
    display: inline-block;
}
.df {
    display: flex;
}
.df-c {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 定位方式 */
.pr {
    position: relative;
}
.pa {
    position: absolute;
}
.pf {
    position: fixed;
}
.zi-1 {
    z-index: 1;
}

/* 浮动方式 */
.fl {
    float: left;
}
.fr {
    float: right;
}
.fn {
    float: none;
}
.clear {
    width: 0;
    height: 0;
    font-size: 0;
    line-height: 0;
    clear: both;
}
.clearfix:after {
    clear: both;
    content: '.';
    display: block;
    visibility: hidden;
    height: 0;
}

/* 列表排列方式 */
.list-fl > li {
    float: left;
}
.list-fl:after {
    content: '.';
    display: block;
    visibility: hidden;
    clear: both;
    height: 0;
}
.list-di > li {
    display: inline;
}

/* 列表1像素细线 */
.list-bb > li,
.list-tb > li {
    position: relative;
}
.list-bb > li:after,
.list-tb > li:after {
    content: ' ';
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    width: 200%;
    height: 200%;
    border-bottom: 0.1rem solid rgba(0, 0, 0, 0.3);
    transform: scale(0.5);
    transform-origin: 0 0;
    pointer-events: none;
}
.list-tb > li:before {
    bottom: auto;
    top: 0;
}
.list-b-c-ddd > li:after,
.list-b-c > li:before {
    border-color: #ddd;
}

/* 鼠标显示方式 */
.cp {
    cursor: pointer;
}
.cd {
    cursor: default;
}

/* 溢出控制方式 */
.oh {
    overflow: hidden;
}
.ox-a {
    overflow: hidden;
    overflow-x: auto;
}
.oy-a {
    overflow: hidden;
    overflow-y: auto;
}
.text-ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 不透明度方式 */
.translucent {
    opacity: 0.5;
}
.transparent {
    opacity: 0;
}
.o_8 {
    opacity: 0.8;
}

/* 圆角0.5细线显示方式 */
.b-b_5,
.b-t_5,
.b-l_5,
.b-r_5,
.b_5 {
    position: relative;
}
.b-b_5:before,
.b-t_5:before,
.b-l_5:before,
.b-r_5:before,
.b_5:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}
.b-b_5:before,
.b-t_5:before {
    width: 100%;
    height: 1px;
    background-color: #999;
    -webkit-transform: scaleY(0.3);
    transform: scaleY(0.3);
}
.b-b_5:before {
    top: auto;
    bottom: 0;
}
.b-l_5:before,
.b-r_5:before {
    width: 1px;
    height: 100%;
    background-color: #999;
    -webkit-transform: scaleX(0.3);
    transform: scaleX(0.3);
}
.b-r_5:before {
    left: auto;
    right: 0;
}
.b_5:before {
    width: 200%;
    height: 200%;
    border: 1px solid #aaa;
    border-radius: inherit;
    -webkit-transform: scale(0.5, 0.5);
    transform: scale(0.5, 0.5);
    pointer-events: none;
}
.b-c-ccc:before {
    border-color: #ccc;
    background-color: #ccc;
}
.b_5.b-c-ccc:before {
    background-color: transparent;
}
.br_5 {
    border-radius: 0.2rem;
}
.br_5:before {
    border-radius: 0.4rem;
}

/* 投影 */
.bs-b {
    box-shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.1);
}

/* 禁用页面弹性拖拽(部分APP中无效,如QQ)*/
.disable-elastic-drag {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值