中文字幕理论片,69视频免费在线观看,亚洲成人app,国产1级毛片,刘涛最大尺度戏视频,欧美亚洲美女视频,2021韩国美女仙女屋vip视频

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
從WeUI學(xué)習(xí)到的知識點(diǎn)

WeUI是微信Web服務(wù)開發(fā)的UI套件, 目前包含12個(gè)模塊 (Button, Cell, Toast, Dialog, Progress, Msg, Article, ActionSheet, Icons, Panel, Tab, SearchBar).

Demo頁面: https://weui.io

Github頁面: https://github.com/weui/weui

下面講一講我從WeUI中學(xué)到的CSS技巧.

Button

從這里我開始注意到, WeUI的實(shí)現(xiàn)中, 很多邊框都是用:before, :after繪制的.

.weui_btn:after {    content: " ";    width: 200%;    height: 200%;    position: absolute;    top: 0;    left: 0;    border: 1px solid rgba(0, 0, 0, 0.2);    -webkit-transform: scale(0.5);    transform: scale(0.5);    -webkit-transform-origin: 0 0;    transform-origin: 0 0;    box-sizing: border-box;    border-radius: 10px;}

這么做是為了在Retina屏(視網(wǎng)膜屏)上確保1px真的是1pixel. 詳見Retina屏的移動(dòng)設(shè)備如何實(shí)現(xiàn)真正1px的線?

Cell

weui_cell

.weui_cell {    padding: 10px 15px;    position: relative;    display: -webkit-box;    display: -webkit-flex;    display: -ms-flexbox;    display: flex;    -webkit-box-align: center;    -webkit-align-items: center;    -ms-flex-align: center;    align-items: center;}

看到這里發(fā)現(xiàn)WeUI大量使用了flex布局方式. 對這個(gè)布局方式我整理了另一篇文章, 見這里.

Cell (列表項(xiàng))

之前一直比較困惑如何實(shí)現(xiàn)列表項(xiàng)之間的, 左邊有些空缺的邊框. border屬性又不支持只顯示一條邊上的一部分, 難道要插入<hr>

WeUI的實(shí)現(xiàn)方式是: 利用.weui_cells:before.

.weui_cell:before {    content: " ";    position: absolute;    left: 15px;    top: 0;    width: 100%;    height: 1px;    border-top: 1px solid #D9D9D9;    color: #D9D9D9;    -webkit-transform-origin: 0 0;    transform-origin: 0 0;    -webkit-transform: scaleY(0.5);    transform: scaleY(0.5);}

left: 15px(左邊的空缺)配合上.weui_cells_titleoverflow: hidden(隱藏右邊超出的部分)就可以顯示有空缺的邊框了.

列表項(xiàng)末尾的右箭頭的實(shí)現(xiàn)方式竟然是weui_cell_ft::after的旋轉(zhuǎn)了45度的border. 我本以為會(huì)用iconfont.

.weui_cells_access .weui_cell_ft:after {    content: " ";    display: inline-block;    -webkit-transform: rotate(45deg);    transform: rotate(45deg);    height: 6px;    width: 6px;    border-width: 2px 2px 0 0;    border-color: #C8C8CD;    border-style: solid;    position: relative;    top: -2px;    top: -1px;    margin-left: .3em;}

Radio (單選列表項(xiàng))

在每個(gè)行內(nèi)部嵌入了一個(gè)隱藏的

<input type="radio" class="weui_check" name="radio1">

隱藏的方式是:

.weui_check {    position: absolute;    left: -9999em;}

在每個(gè)input.weui_check的后面放置了一個(gè)用于顯示對勾的span. input.weui_check.weui_icon_checked是兄弟關(guān)系.

<span class="weui_icon_checked"></span>
.weui_cells_radio .weui_check:checked + .weui_icon_checked:before {    display: block;    content: '\EA08';    color: #09BB07;    font-size: 16px;}

Checkbox (復(fù)選列表項(xiàng))

復(fù)選框如上面的單選框一樣被隱藏了.

<input type="checkbox" class="weui_check" name="checkbox1">

比較出乎我意料的是選中和未被選中的效果都是用iconfont實(shí)現(xiàn)的. 本以為未被選中的效果是用border實(shí)現(xiàn), 選中效果用一個(gè)check的iconfont配合水平豎直居中定位.

/* 選中效果 */.weui_cells_checkbox .weui_check:checked + .weui_icon_checked:before {    content: '\EA06';    color: #09BB07;}/* 未選中效果 */.weui_cells_checkbox .weui_icon_checked:before {    content: '\EA01';    color: #C9C9C9;    font-size: 23px;    display: block;}

Switch (開關(guān))

<input class="weui_switch" type="checkbox">

之前覺得這個(gè)效果很難做啊, 看了weui的實(shí)現(xiàn)竟然只用css就行了!

.weui_switch {  -webkit-appearance: none;  -moz-appearance: none;  appearance: none;  position: relative;  width: 52px;  height: 32px;  border: 1px solid #DFDFDF;  outline: 0;  border-radius: 16px;  box-sizing: border-box;  background: #DFDFDF;}.weui_switch:checked {  border-color: #04BE02;  background-color: #04BE02;}.weui_switch:before {  content: " ";  position: absolute;  top: 0;  left: 0;  width: 50px;  height: 30px;  border-radius: 15px;  border-top-left-radius: 15px;  border-top-right-radius: 15px;  border-bottom-right-radius: 15px;  border-bottom-left-radius: 15px;  background-color: #FDFDFD;  -webkit-transition: -webkit-transform .3s;  transition: -webkit-transform .3s;  transition: transform .3s;  transition: transform .3s, -webkit-transform .3s;}.weui_switch:checked:before {  -webkit-transform: scale(0);  transform: scale(0);}.weui_switch:after {  content: " ";  position: absolute;  top: 0;  left: 0;  width: 30px;  height: 30px;  border-radius: 15px;  background-color: #FFFFFF;  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);  -webkit-transition: -webkit-transform .3s;  transition: -webkit-transform .3s;  transition: transform .3s;  transition: transform .3s, -webkit-transform .3s;}.weui_switch:checked:after {  -webkit-transform: translateX(20px);  transform: translateX(20px);}

其中, .weui_switch提供了邊框, 未選中時(shí)背景色#DFDFDF(深灰), 選中時(shí)#04BE02(綠色).

.weui_switch:before提供了邊框內(nèi)部的淺灰色#FDFDFD. 被選中時(shí)scale(0)縮小消失.

.weui_switch:after提供了圓形按鍵. 被選中時(shí)向右邊移動(dòng)20px.

效果如下:

Form (表單)

<input class="weui_input" type="number" pattern="[0-9]*" placeholder="請輸入qq號">

inputpattern="[0-9]*限制了輸入只能是0-9的數(shù)字(pattern的值是正則表達(dá)式).

input[type="number"]在Chrome上默認(rèn)會(huì)在最右邊顯示上下箭頭. WeUI通過下面的代碼禁用了箭頭, 這段代碼在Chrome的Dev Tool里面是看不到的, 只能從CSS里面看, 害我找了半天.

.weui_input::-webkit-outer-spin-button,.weui_input::-webkit-inner-spin-button {  -webkit-appearance: none;  margin: 0;}

相關(guān): 在iOS上會(huì)自動(dòng)打開數(shù)字鍵盤.

Upload (上傳)

WeUI用下面這個(gè)簡單的方法實(shí)現(xiàn)了圖片前面的灰層. absolute定位加上top:0; right:0; bottom:0; left:0;就會(huì)讓元素被抻開到父元素的邊界.

圖片上傳狀態(tài)用了一個(gè)經(jīng)典的(水平+垂直)居中方式, 利用top: 50%(讓元素的上邊界定位到父元素的50%位置)和transform: translateY(-50%)(讓元素往上移動(dòng)元素自身高度的50%).

我平時(shí)常用的垂直居中方式如下. 水平居中類似.

最后的上傳按鈕:

input[type="file"]在iOS上會(huì)自動(dòng)觸發(fā)選擇"拍照"還是"照片"的菜單.

方框是用.weui_uploader_input_wrp畫出來的, 而加號是用.weui_uploader_input_wrp:before:after.

真正的input利用opacity:0隱藏起來了.

Form Error (表單報(bào)錯(cuò))

在iOS上, 點(diǎn)選input[type="date"]會(huì)出現(xiàn)"年-月-日"的選擇框, 點(diǎn)選input[type="datetime-local"]會(huì)出現(xiàn)"月-日-上午/下午-時(shí)-分"的選擇框.

Select (選擇)

電話號碼+86位置的右箭頭和分割線是用:before:after繪制的.

Toast

.weui_mask_transparent就是一個(gè)position:fixed占滿全屏的透明幕布, 讓用戶無法操作界面.

.weui_toast才是頁面中間的黑塊.

竟然是純用HTML+CSS(animation+transition)實(shí)現(xiàn)的.

<div id="loadingToast" class="weui_loading_toast" style="/* display: none; */">    <div class="weui_mask_transparent"></div>    <div class="weui_toast">        <div class="weui_loading">            <div class="weui_loading_leaf weui_loading_leaf_0"></div>            <div class="weui_loading_leaf weui_loading_leaf_1"></div>            <div class="weui_loading_leaf weui_loading_leaf_2"></div>            <div class="weui_loading_leaf weui_loading_leaf_3"></div>            <div class="weui_loading_leaf weui_loading_leaf_4"></div>            <div class="weui_loading_leaf weui_loading_leaf_5"></div>            <div class="weui_loading_leaf weui_loading_leaf_6"></div>            <div class="weui_loading_leaf weui_loading_leaf_7"></div>            <div class="weui_loading_leaf weui_loading_leaf_8"></div>            <div class="weui_loading_leaf weui_loading_leaf_9"></div>            <div class="weui_loading_leaf weui_loading_leaf_10"></div>            <div class="weui_loading_leaf weui_loading_leaf_11"></div>        </div>        <p class="weui_toast_content">數(shù)據(jù)加載中</p>    </div></div>
.weui_loading_leaf {  position: absolute;  top: -1px;  opacity: 0.25;}.weui_loading_leaf:before {  content: " ";  position: absolute;  width: 8.14px;  height: 3.08px;  background: #d1d1d5;  box-shadow: rgba(0, 0, 0, 0.0980392) 0px 0px 1px;  border-radius: 1px;  -webkit-transform-origin: left 50% 0px;          transform-origin: left 50% 0px;}.weui_loading_leaf_0 {  -webkit-animation: opacity-60-25-0-12 1.25s linear infinite;          animation: opacity-60-25-0-12 1.25s linear infinite;}.weui_loading_leaf_0:before {  -webkit-transform: rotate(0deg) translate(7.92px, 0px);          transform: rotate(0deg) translate(7.92px, 0px);}/* ... */.weui_loading_leaf_11 {  -webkit-animation: opacity-60-25-11-12 1.25s linear infinite;          animation: opacity-60-25-11-12 1.25s linear infinite;}.weui_loading_leaf_11:before {  -webkit-transform: rotate(330deg) translate(7.92px, 0px);          transform: rotate(330deg) translate(7.92px, 0px);}@-webkit-keyframes opacity-60-25-0-12 {  0% {    opacity: 0.25;  }  0.01% {    opacity: 0.25;  }  0.02% {    opacity: 1;  }  60.01% {    opacity: 0.25;  }  100% {    opacity: 0.25;  }}/* ... */@-webkit-keyframes opacity-60-25-11-12 {  0% {    opacity: 0.895958333333333;  }  91.6767% {    opacity: 0.25;  }  91.6867% {    opacity: 1;  }  51.6767% {    opacity: 0.25;  }  100% {    opacity: 0.895958333333333;  }}

4. Dialog

你能看到的邊框都是用:after實(shí)現(xiàn)的.

5. Progress

略. ( *?ω?)?╰ひ╯

6. Msg

略. ( *?ω?)?╰ひ╯

7. Article

略. ( *?ω?)?╰ひ╯

8. ActionSheet

值得一提的是, 頁面下方的ActionSheet始終是顯示的, 只不過平時(shí)通過transform: translateY(100%)隱藏了起來, 顯示時(shí)用translateY(0). 這方法無需JS就可以自適應(yīng)任意高度的ActionSheet.

9. Icons

一堆iconfont. ( *?ω?)?╰ひ╯

10. Panel

略. ( *?ω?)?╰ひ╯

11. Tab

Navbar:

TabBar:

略. ( *?ω?)?╰ひ╯

12. SearchBar

無焦點(diǎn)狀態(tài):

有焦點(diǎn)狀態(tài):

這里我最好奇的是, 當(dāng)用戶點(diǎn)擊搜索框時(shí), 彈出的鍵盤上右下角的按鍵是"搜索"而不是"換行".

我測試的效果是, 在微信中點(diǎn)擊搜索框時(shí)鍵盤顯示"搜索"按鍵, 在Safari中打開時(shí)則顯示"換行".

這就很詭異了, 說明微信做了什么手腳. 難道與JS有關(guān)?

但是我在網(wǎng)上搜索了下, 發(fā)現(xiàn)只要確保input[type="search"]form包圍, 且formaction屬性即可. 示例:

但是WeUI的實(shí)現(xiàn)中, form并沒有action屬性, 所以暫時(shí)不知道WeUI是如何做的. 

打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
【聊代碼】第九十五集 css樣式(之六十五)圖片自動(dòng)循環(huán)縮放|老小孩講述
微信開發(fā)系列<a style="color: rgb(0, 0, 0); font-size: 14px; font-weight: 400;">WeUI組件</
使用CSS3和JavaScript創(chuàng)建一個(gè)光滑,動(dòng)畫的全屏搜索表單
angular指令插件1
超贊圓形動(dòng)畫進(jìn)度條,愛了愛了(使用HTML、CSS和bootstrap框架)
CSS3實(shí)現(xiàn)0.5px的邊框
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服