常用前端代码资源(转)
转自https://github.com/jsfront/src/blob/master/css.md
以下是常用的代码收集,没有任何技术含量,只是填坑的积累。转载请注明出处,谢谢。
1. css 2.x
- 文字换行
/*强制不换行*/
white-space:nowrap;
/*自动换行*/
word-wrap: break-word;
word-break: normal;
/*强制英文单词断行*/
word-break:break-all;
- 两端对齐
text-align:justify;text-justify:inter-ideogra
- 去掉Webkit(chrome)浏览器中input(文本框)或textarea的黄色焦点框
input,button,select,textarea{ outline:none;} textarea{ font-size:13px; resize:none;}
去掉chrome记住密码后自动填充表单的黄色背景
ie6: position:fixed
.fixed-top /* position fixed Top */{position:fixed;bottom:auto;top:0; } * html .fixed-top /* IE6 position fixed Top */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));} *html{background-image:url(about:blank);background-attachment:fixed;}
- clearfix
.clearfix:after{visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;} .clearfix{display:inline-block;} html[xmlns] .clearfix{display:block;} * html .clearfix{height:1%;} .clearfix{*zoom: 1;} .clearfix:after{clear:both;display:table;content:"”;} .clearfix{overflow:hidden;_zoom:1;}
http://www.daqianduan.com/3606.html
- seperate-table
.tab{border-collapse:separate;border:1px solid #e0e0e0;} .tab th,.tab td{padding:3px;font-size:12px;background:#f5f9fb;border:1px solid;border-color:#fff #deedf6 #deedf6 #fff;} .tab th{background:#edf4f0;} .tab tr.even td{background:#fff;}
<table class="tab" width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <th>111</th> <td>222</td> </tr> <tr> <th>111</th> <td>222</td> </tr> </table>
- min-height: 最小高度兼容代码
.minheight500{min-height:500px;height:auto !important;height:500px;overflow:visible;}
- 鼠标不允许点击
cursor:not-allowed;
- mac font: osx平台字体优化
font-family:"Hiragino Sans GB","Hiragino Sans GB W3",'微软雅黑';
- 文字过多后显示省略号
.ellipsis,.ell{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2. css 3
- title 换行
- 关闭 x 符号
×
- 投影
.b{box-shadow:inset 1px -1px 0 #f1f1f1;text-shadow:1px 1px 0px #630;} filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#99000000',endColorstr='#99000000');background:rgba(0,0,0,.6); background:rgba(0,0,0,0.5);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#50000000',endColorstr='#50000000')\9;
- search占位
::-webkit-input-placeholder {}
::-moz-input-placeholder {}
input:focus::-webkit-input-placeholder { color: transparent; } -webkit-appearance:none; google边框去除 input[type="search"]{-webkit-appearance:textfield;} // 去除chrome默认样式 http://i.wanz.im/2011/02/04/remove_border_from_input_type_search/ http://blog.csdn.net/do_it__/article/details/6789699 line-height: normal; /* for non-ie */ line-height: 22px\9; /* for ie */
全部浏览器的兼容代码生成 CSS 实现 textArea 的 placeholder 换行
阻止默认事件
pointer-events:none;
- 去掉输入框聚焦时候的白色背景
-webkit-user-modify: read-write-plaintext-only;
- input:focus时input不随软键盘升起而抬高的情况
:focus{-webkit-tap-highlight-color:rgba(255, 255, 255, 0);-webkit-user-modify:read-write-plaintext-only;}
- 变灰 gray
html{filter: grayscale(100%);-webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(1); }
- firefox 阻止选中
-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:none;
- 箭头
display:block;border:solid transparent;line-height: 0;width:0; height:0;border-top:solid #0288ce;border-width:8px 6px 0 6px;border-style:solid; border-width:7px; border-color:transparent transparent transparent #ff7020;
position:absolute;top: 0;left: 0;border-width:20px;border-style:solid;border-color:#d1ddde transparent transparent #d1ddde;
ie6 bug测试,把border-style设为dashed.
- 取消textarea右下角可拖动手柄
resize:none
- 取消chrome form表单的聚焦边框
input,button,select,textarea{outline:none} textarea{resize:none}
- 取消a链接的黄色边框
a{-webkit-tap-highlight-color:rgba(0,0,0,0);}
- 取消input,button焦点或点击时蓝色边框
input{outline:none;}
- webkit 水平居中
display:-webkit-box;-webkit-box-pack:center; -webkit-box-align: center;
position:absolute; top:50%;left:50%;transform:translate(-50%,-50%);
- 取消chrome 搜索x提示
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration { display: none; }
- chrome取消默认黄色背景
input:-webkit-autofill {-webkit-box-shadow: 0 0 0px 1000px white inset;} input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px white inset; } autocomplete="off"
- 手机版本网页a标记虚线框问题
a:focus {outline:none;-moz-outline:none;}
- 焦点去除背景
-webkit-tap-highlight-color:rgba(255, 255, 255, 0);
-webkit-tap-highlight-color:transparent; // i.e. Nexus5/Chrome and Kindle Fire HD 7''
- placeholder占位符颜色自定义
input:-moz-placeholder {color: #369;}
::-webkit-input-placeholder {color:#369;}
- IOS 禁用高亮
-webkit-tap-highlight-color:rgba(255,0,0,0.5);-webkit-tap-highlight-color:transparent; /* For some Androids */
- IOS iframe 滚动 滚动回弹特效
-webkit-overflow-scrolling:touch;overflow-y:scroll;
- 禁止选中文本
-moz-user-select:none;
-webkit-user-select:none;
-ms-user-select:none;
user-select:none;
- 模糊(毛玻璃)效果1
- 模糊(毛玻璃)效果2
- 模糊(毛玻璃)逼真效果
.blur { -webkit-filter: blur(10px); /* Chrome, Opera */ -moz-filter: blur(10px); -ms-filter: blur(10px); filter: blur(10px); }
<img src="mm1.jpg" />
<img src="mm1.jpg" class="blur" />
- 显示旋转加载图片,下拉加载数据
#pullDown .pullDownIcon{display:inline-block;vertical-align:middle;width:40px;height:40px;background:url(https://github.com/chalecao/chale/blob/master/pull-icon%402x.png) 0 0 no-repeat;-webkit-background-size:40px 80px;background-size:40px 80px;-webkit-transition-property:-webkit-transform;-webkit-transition-duration:250ms} #pullDown .pullDownIcon{-webkit-transform:rotate(0deg) translateZ(0)} #pullDown .pullDownLabel{display:inline-block;vertical-align:middle;margin-left:5px;} #pullDown.flip .pullDownIcon{-webkit-transform:rotate(-180deg) translateZ(0)} #pullDown.loading .pullDownIcon{background-position:0 100%;-webkit-transform:rotate(0deg) translateZ(0);-webkit-transition-duration:0ms;-webkit-animation-name:loading;-webkit-animation-duration:2s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear} @-webkit-keyframes loading{ from{-webkit-transform:rotate(0deg) translateZ(0)} to{-webkit-transform:rotate(360deg) translateZ(0)} }
<div id="pullDown" class="none loading"> <span class="pullDownIcon"></span><span class="pullDownLabel">正在载入中...</span> </div>
- 手机多终端适配 media queryweb app iphone4 iphone5 iphone6 响应式布局 适配代码
@media (device-height:480px) and (-webkit-min-device-pixel-ratio:2){/* 兼容iphone4/4s */ .class{} } @media (device-height:568px) and (-webkit-min-device-pixel-ratio:2){/* 兼容iphone5 */ .class{} } @media (device-height:667px) and (-webkit-min-device-pixel-ratio:2){/* 兼容iphone6 */ .class{} } @media (device-height:736px) and (-webkit-min-device-pixel-ratio:2){/* 兼容iphone6 Plus */ .class{} }
- 屏蔽苹果浏览器对数字的识别Meta标签中的format-detection属性及含义
<meta content="telephone=no" name="format-detection">
移除HTML5 input在type="number"时的上下小箭头
- 在chrome下:
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance: none !important; margin: 0; }
- Firefox下:
input[type="number"]{-moz-appearance:textfield;}
- 第二种方案:
- 将type="number"改为type="tel",同样是数字键盘,但是没有箭头。
HTML5手机浏览直接给一个号码打电话,发短信
<a href="tel:15222222222">移动WEB页面JS一键拨打号码咨询功能</a> <a href="sms:15222222222">移动WEB页面JS一键发送短信咨询功能</a> <!--移动web页面自动探测电话号码--> <meta name="format-detection" content="telephone=no"> <meta http-equiv="x-rim-auto-match" content="none">
- CSS判断横屏竖屏
@media screen and (orientation: portrait) {/*竖屏 css*/ } @media screen and (orientation: landscape) { /*横屏 css*/ }
//判断手机横竖屏状态:
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() { if (window.orientation === 180 || window.orientation === 0) { alert('竖屏状态!'); } if (window.orientation === 90 || window.orientation === -90 ){ alert('横屏状态!'); } }, false); //移动端的浏览器一般都支持window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态。
rem 适配,内容太多,只贴网址
- rem自适应方案
- html5移动端页面分辨率设置及相应字体大小设置的靠谱使用方式
- 移动端高清、多屏适配方案
- 通过rem布局+media-query:aspect-ratio实现移动端全机型适配覆盖
- web app变革之rem
- 手机淘宝的flexible设计与实现
- 移动端自适应方案
- 【原创】移动端高清、多屏适配方案
- 6个html5页面适配iphone6的技巧
- 关于移动端 rem 布局的一些总结
- 从网易与淘宝的font-size思考前端设计稿与工作流
- 移动端自适应方案
- MobileWeb 适配总结
- 移动端web app自适应布局探索与总结
公式
var PAGE_MAX_WIDTH = 1280,BASE_FONT_SIZE = 50; (function() { function n() { e.fontSize = Math.min(window.innerWidth / PAGE_MAX_WIDTH * BASE_FONT_SIZE, BASE_FONT_SIZE) + "px" } var e = document.documentElement.style; window.addEventListener("load", n), window.addEventListener("resize", n), n(); }());
转载于:https://www.cnblogs.com/zpfind/p/5506336.html
常用前端代码资源(转)相关推荐
- 网易智慧企业 Node.js 实践(2)| 平滑发布和前端代码
健康检查 前文提到我们通过网关把流量转发到 Node 应用,那网关是如何确定 Node 应用的可用性呢? 如果 Node 应用在发布的过程中也把流量转发过来,就会导致请求失败,所以我们的网关会对 No ...
- 常用前端资源网站集合
常用的学习资源网站: 前端导航(一款前端网站集合的网站): https://docs.pfan123.com/ 知识点类: https://cloud.tencent.com/developer/ar ...
- css宋体代码_前端开发必备的CSS命名规范与常用CSS代码集合
编辑 | web前端开发 来源 | web前端开发 我们在用html+css进行网页的排版布局时,经常会遇到CSS命名,如果是在团队多人协作开发时,团队里都会有自己的命名规范与要求. 但如果是自己在个 ...
- Web前端开发最佳实践(3):前端代码和资源的压缩与合并
一般在网站发布时,会压缩前端HTML.CSS.JavaScript代码及用到的资源文件(主要是图片文件),目的是加快文件在网络中的传输,让网页更快的展现.当然,CDN分发.缓存等方式也是加快代码或资源 ...
- html是用cdn资源,网站常用前端公共库CDN服务资源(百度+360)
谷歌最近很不稳定,模板无忧原本使用的google cdn的Jquery库,因为google服务器问题,导致网站打开速度超慢. 严重影响了网站体验,特整理了本篇文章,分享一下国内的各类常用资源cdn公用 ...
- 常用前端JS代码与JS方法
[返回Z平台-帮助文档-首页] Z平台的核心JS方法都存储在 /webapp/js/z.js 文件中,如果想更全面的学习Z平台的开发,建议大家熟读该文件.平台前端的核心JS方法都在这. 共用JS方法 ...
- 基于Vue的校园资源管理系统(前端代码)
基于Vue的校园资源管理系统(前端代码) 作者:Jackshijin 项目背景 这是本人在毕业的时候选择的毕业设计方向,指导老师团队的课题有小程序.安卓开发.机器学习和嵌入式,而我选择了Web...因 ...
- 极客Web前端开发资源大荟萃
每周极客都将总结本周最精彩的素材提供给大家,希望可以带给你更多地灵感和帮助!极客#GB课程库#现已上线,无论你是初级.中级.还是正在进修的高级前端工程师.这里都将帮助你得到更多更高效的学习. #GB课 ...
- grunt 打包前端代码
[grunt整合版]30分钟学会使用grunt打包前端代码 grunt 是一套前端自动化工具,一个基于nodeJs的命令行工具,一般用于: ① 压缩文件 ② 合并文件 ③ 简单语法检查 对于其他用法, ...
最新文章
- yii2快速導出phpexcel
- C#用户权限控制架构,可以控制到类【重发】
- 杭电多校第三场-H-Game
- go map并发写错误问题
- 最优化(part1)--近似点梯度法
- 采蘑菇的克拉莉丝(树链剖分)
- 计算机桌面图标变成腾讯图标,桌面图标变成了未知图标
- 开发指南专题二:JEECG微云快速开发平台JEECG框架初探
- 如何在 macOS Monterey 中更改光标颜色
- 使用jmeter测试接口
- 再回首Java第二十二天
- VB中连接access数据库的几种方法
- charset参数 sqluldr2_sqluldr2.bin数据库导出工具
- html语言怎么修改form边框,form表单样式案例 定义html表单细边框样式
- java前后端分离,前端部署的方式
- ThinkPHP高仿蓝奏云网盘系统源码/对接易支付系统程序
- 如何在kylo中添加数据源
- Tidabie Tidal Music 潮汐音乐下载转换器
- 信息化项目中服务器费用占比,企业信息化投入是什么 它的占比是多少
- python 实现发送手机短信验证码后台方法
热门文章
- STM32H743+CubeMX-ADC(16bit分辨率)+DMA采样三路模拟量,硬件过采样器实现1024倍过采样
- latex附录中放python代码_在Latex中插入Python代码
- Linux笔记-centos安装elasticsearch7版本
- PythonRabbitmq文档阅读笔记-生产者数据直接送入队列消费者消费
- C++设计模式-使用Qt框架模拟策略模式(Strategy)+简单工厂实现商场促销
- Linux工作笔记-解决spawn: not found与expect: not found问题(安装expect)
- 大三软件工程小项目-小技术集合-读取XML文件及运行外部程序
- C/C++ OpenCV直方图均衡化
- 3dcaptcha php,php实现的Captcha验证码类实例
- onedrive电脑手机不同步_免费的手机电脑同步便签软件怎么找?求帮忙推荐