日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

常用前端代码资源(转)

發布時間:2025/3/15 HTML 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 常用前端代码资源(转) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自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 換行
&#13;
  • 關閉 x 符號
&#215;
  • 投影
.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

總結

以上是生活随笔為你收集整理的常用前端代码资源(转)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。