UNPKG

tool.less

Version:
283 lines (270 loc) 4.79 kB
// reset === html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } // ==== // myreset === html, body { background: transparent; -webkit-text-size-adjust: 100%; /*关闭字体大小自动调整功能*/ -ms-text-size-adjust: 100%; touch-action: manipulation; /*取消双击放大,避免300ms的延迟,不过FF不支持;*/ height: 100%; /*如果 <body> 及其子元素的高度需要设置为窗口高度时, /*可以让页面在Native端滚动时模拟原生的弹性滚动效果 局部滚动(仅iOS5 以上支持)*/ -webkit-overflow-scrolling: touch; /* 禁用长按页面时的弹出菜单(iOS下有效), img和a标签都要加 */ -webkit-touch-callout: none; } body * { -webkit-backface-visibility: hidden; backface-visibility: hidden; /* 隐藏转换的元素的背面 */ -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } img { border: none; vertical-align: middle; } button, input, select, textarea { outline: none; border: none; padding: 0; box-sizing: border-box; font-size: 14px; transition: border 0.2s ease-in-out, background 0.2s ease-in-out, box-shadow 0.2s ease-in-out; background: transparent; box-shadow: none; -webkit-appearance: none; /* 除输入框和按钮的原生外观,在iOS上加上这个属性才能给按钮和输入框自定义样式 */ vertical-align: middle; line-height: normal; //光标问题 resize: none; } /*placeholder颜色*/ input::-moz-placeholder, textarea::-moz-placeholder { color: #ccc; text-overflow: ellipsis; } input:-ms-input-placeholder, textarea:-ms-input-placeholder { color: #ccc; text-overflow: ellipsis; } /*注意它是一个冒号,textarea里面用的是input*/ input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #ccc; text-overflow: ellipsis; } // 如果需要定制颜色的话 // input[type=tel] //手机号 // input[type=number] //数字 // input[type=search] //搜索 // 禁用的样式 input:disabled, input[disabled] { color: #000; // -webkit-text-fill-color: #999; -webkit-opacity: 1; opacity: 1; } :focus { /* 防止在获得焦点时, 出现边框 */ outline: none; -webkit-tap-highlight-color: transparent; } // --清除谷歌浏览器下的 search 叉号 input::-webkit-search-cancel-button { display: none; } // --清除IE下的 search 叉号 input[type='search']::-ms-clear { display: none; } // ==== .select-none { /*禁止选中文本*/ -webkit-user-select: none; -ms-user-select: none; user-select: none; } // 文字超出两行隐藏 .text-ellipsis(@line) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: @line; overflow: hidden; } .text-ellipsis2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } // 文字超出一行隐藏 .text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } // 清浮动 .clearfix { &:after { content: ''; height: 0; display: block; overflow: hidden; clear: both; } } .fl { float: left; } .fr { float: right; } // TIP: 扩大点击范围 (使用时注意伪类冲突) .tap-area { position: relative; &::before { content: ''; position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; } } .break-word { word-break: break-all; /* 支持IE和chrome,FF不支持*/ word-wrap: break-word; /* 以上三个浏览器均支持 */ }