close
文章出處
寫在前面
寫的一模一樣的css樣式,結果卻導致原來出來不一樣的效果圖。
用chrome的開發者工具查看,比較起來還是一模一樣的css樣式,可為什么會出現不一樣的placeholder效果呢?一個白色粗體,一個灰色正常字體。
找了老半天找不到原因
后來才發現是我同事寫的框架css里面代碼的一句話影響到了
::-webkit-input-placeholder { color: #a4afc6; }
可是為什么在chrome控制臺看不到這句代碼呢?請教了一番同事,原來是這樣的。
1、點擊控制臺“設置”按鈕
2、按如下所示設置,選中“Show user agent shadow DOM”
3、你就會在elements控制面板里面能看到如下所示
回歸正題,繼續我的css各種圖標。。。。
當然在開始之前,還是加上如下這段公共樣式吧!
[class^="u-icon"] { display: inline-block; color: #fff; vertical-align: middle; }
各種刪除按鈕(不用圖標只能css來實現)
html代碼如下:
<span class="u-icon-radioDelete"></span> <span class="u-icon-deleteToggle Orange"> <span class="u-icon-trash"></span>刪除 </span> <span class="u-icon-deleteToggle Blue"> <span class="u-icon-grayTrash"></span>刪除 </span> <span class="u-icon-del"></span> <span class="u-icon-del on"></span> <span class='u-icon-sel more'>搜索更多</span> <span class='u-icon-sel on'>搜索更多</span> <span class='u-icon-delete'><i></i></span>
頁面顯示效果如下:
css樣式代碼:
.u-icon-sel { position: relative; -webkit-box-sizing: border-box; width: 32%; height: 32px; line-height: 30px; margin-bottom: 4px; border: 1px solid #a4afc6; border-radius: 3px; color: #a4afc6; text-align: center; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } .u-icon-sel.on { overflow: hidden; border-color: #ff5d1d; color: #000; } .u-icon-sel.on:before { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; background: url(http://webresource.c-ctrip.com/ResCorpMobile/R1/img/common-graphic37.png?20150423) no-repeat -23px -152px/150px 240px; content: ''; } .u-icon-sel.more { color: #6daeee; } .u-icon-deleteToggle { width: 75px; height: 45px; line-height: 45px; text-align: center; } .u-icon-deleteToggle.Blue { background-color: #3e74b9; } .u-icon-deleteToggle.Orange { background-color: #ff5d1d; } /*白色垃圾桶、灰色垃圾桶圖標*/ .u-icon-trash,.u-icon-grayTrash { background: url(http://webresource.c-ctrip.com/ResCorpMobile/R1/img/common-graphic37.png?20150423) no-repeat 0 0/150px 240px; } .u-icon-trash { background-position: 0 -84px; width: 16px; height: 18px; } .u-icon-grayTrash { display: inline-block; width: 12px; height: 18px; margin-right: 8px; vertical-align: -2px; background-position: -3px -178px; } /*不用任何圖標實現刪除icon效果*/ .u-icon-delete { position: absolute; bottom: 5px; right: 0; width: 40px; height: 40px; } /*給before偽類設置一個默認背景色 設置content*/ .u-icon-delete:before { position: absolute; top: 10px; left: 10px; width: 20px; height: 20px; border-radius: 20px; background-color: #8e8e93; content: ''; } /*給after偽類 -webkit-transform: rotate(-45deg);旋轉 background-color: #e1e2e4;設置X的一邊的顏色*/ .u-icon-delete:after { position: absolute; top: 19px; left: 14px; width: 12px; height: 2px; -webkit-transform: rotate(-45deg); background-color: #e1e2e4; content: ''; } /* -webkit-transform: rotate(45deg); 運用的特別巧秒*/ .u-icon-delete i { position: absolute; top: 19px; left: 14px; width: 12px; height: 2px; background-color: #e1e2e4; -webkit-transform: rotate(45deg); } /*橙色背景中間一白色橫杠的刪除icon */ .u-icon-del { position: relative; width: 24px; height: 24px; border: 1px solid #ff5d1d; -webkit-border-radius: 24px; border-radius: 24px; -webkit-transition: 300ms ease-in-out; transition: 300ms ease-in-out; background-color: #ff5d1d; } .u-icon-del.on,.on .u-icon-del { -webkit-transform: rotateZ(90deg); } /*這里的background-color: #fff;和 content: "\20";實現白色橫杠*/ .u-icon-del::after { position: absolute; top: 10px; left: 4px; width: 16px; height: 4px; background-color: #fff; content: "\20"; } .u-icon-radioDelete { position: relative; width: 24px; height: 24px; border: 1px solid #8AADD8; -webkit-border-radius: 24px; border-radius: 24px; -webkit-transition: 300ms ease-in-out; transition: 300ms ease-in-out; } .u-icon-radioDelete::after { position: absolute; top: 11px; left: 4px; width: 16px; height: 2px; background-color: #8AADD8; color: #8AADD8; content: "\20"; } .u-icon-radioDelete.on,.on .u-icon-radioDelete { -webkit-transform: rotateZ(90deg); -ms-transform: rotateZ(90deg); }
加加減減圖標
html代碼如下:
<i class='u-icon-plus on'></i> <i class='u-icon-minus on'></i> <i class='u-icon-plus '></i> <i class='u-icon-minus '></i> <span class="u-icon-addS"></span> <span class="u-icon-addB"></span>
頁面顯示效果如下:
css樣式代碼:
/*加減標簽*/ /*加標簽icon*/ .u-icon-addS, .u-icon-addB { width: 60px; height: 40px; } /*加的大icon*/ .u-icon-addB { position: relative; top: 0; right: 0; } /*加的小icon*/ .u-icon-addS { position: relative; color: #3B8FF8; } .u-icon-addS::before,.u-icon-addS::after, .u-icon-addB::before,.u-icon-addB::after { position: absolute; top: 20px; left: 25px; width: 12px; content: ""; } .u-icon-addB::before, .u-icon-addB::after { border-top: 1px solid #fff; } .u-icon-addS::before,.u-icon-addS::after { border-top: 2px solid #3B8FF8; } .u-icon-addB::after,.u-icon-addS::after { -webkit-transform: rotateZ(90deg); transform: rotateZ(90deg); } /*加、減按鈕*/ .u-icon-plus, .u-icon-minus { position: relative; width: 30px; height: 3px; background-color: #a9b3c9; box-shadow: 0 1px 1px #959bab inset; border-radius: 3px; } .u-icon-plus.on, .u-icon-minus.on,.on.u-icon-plus::before, .on .u-icon-plus,.on .u-icon-minus ,.on .u-icon-plus ::before { background-color: #6daeee; box-shadow: 0 1px 1px #6a9aca inset; } .u-icon-plus::before { position: absolute; left: 13px; width: 3px; height: 30px; border-radius: 3px; box-shadow: 1px 0 1px #959bab inset; background-color: #a9b3c9; -webkit-transform: translate(0,-13.5px); transform: translate(0,-13.5px); text-align: center; content: ""; }
問號圖標
html代碼如下:
<span class="u-icon-qa"></span>
頁面顯示效果如下:
css樣式代碼:
.u-icon-qa { width: 60px; height:44px; text-align: center; color: #FFFFFF; font-size: 18px; } .u-icon-qa:before { position: absolute; top:10px; right: 15px; width: 24px; height: 24px; background: #67a5e2; -webkit-border-radius: 24px; border-radius: 24px; content: ''; } .u-icon-qa:after { position: absolute; top:10px; right: 22px; content: '?'; }
一行被選中狀態圖標
html代碼如下:
<span class="u-icon-checkTitle"></span>
頁面顯示效果如下:
css樣式代碼:
.u-icon-checkTitle { position: absolute; top: 9px; right: 13px; width: 16px; height: 16px; border-radius: 100%; background: #fff; content: ''; } .u-icon-checkTitle::after { position: absolute; top: 2px; right: 5px; width: 4px; height: 8px; border-width: 0 2px 2px 0; border-color: #ffa124; border-style: solid; -webkit-transform: rotate(45deg); content: ''; }
未完待續(如果大家有更好的方法來實現,不用圖片,可以麻煩與我交流一下,謝謝!)
如果您覺得本篇博文對您有所收獲,覺得小女子還算用心,請點擊右下角的 [推薦],謝謝!
![]() |
不含病毒。www.avast.com |
全站熱搜