国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 22:19:12
文檔

vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例

vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例:前言 本文題目中雖然寫有vue和react,但是并非vue和react相關(guān)知識(shí),而是最基本的html5和css3的一些知識(shí),之所以寫vue,是因?yàn)槲易罱?xiàng)目中用到了類似效果,我用vue相關(guān)知識(shí)實(shí)現(xiàn)并不雅觀,用html5和css3實(shí)現(xiàn),則更加完美。 項(xiàng)目案例 項(xiàng)目中有如下效果: 好
推薦度:
導(dǎo)讀vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例:前言 本文題目中雖然寫有vue和react,但是并非vue和react相關(guān)知識(shí),而是最基本的html5和css3的一些知識(shí),之所以寫vue,是因?yàn)槲易罱?xiàng)目中用到了類似效果,我用vue相關(guān)知識(shí)實(shí)現(xiàn)并不雅觀,用html5和css3實(shí)現(xiàn),則更加完美。 項(xiàng)目案例 項(xiàng)目中有如下效果: 好

前言

本文題目中雖然寫有vue和react,但是并非vue和react相關(guān)知識(shí),而是最基本的html5和css3的一些知識(shí),之所以寫vue,是因?yàn)槲易罱?xiàng)目中用到了類似效果,我用vue相關(guān)知識(shí)實(shí)現(xiàn)并不雅觀,用html5和css3實(shí)現(xiàn),則更加完美。

項(xiàng)目案例

項(xiàng)目中有如下效果:

好多展開收起,對(duì)于這個(gè)的實(shí)現(xiàn),我一開始用了vue一些比較挫的dom操作,就是父元素toggleClass一個(gè)類名,進(jìn)行子元素的顯示和隱藏。

由于這個(gè)方法是通用方法,項(xiàng)目中好多地方使用,代碼大概如下:

toggleShow() {
 let target = window.event.srcElement;
 if (target.nodeName == "SPAN") {
 target.parentNode.parentNode.classList.toggle("toggleclass");
 target.classList.toggle("el-icon-arrow-right");
 } else {
 target.parentNode.classList.toggle("toggleclass");
 target.children[0].classList.toggle("el-icon-arrow-right");
 }
}

這樣寫,既不友好,后期又難以維護(hù)。最近重構(gòu)項(xiàng)目的時(shí)候,把這些地方都重構(gòu)了,用了今天介紹的方法!更多重構(gòu)要點(diǎn),請(qǐng)點(diǎn)擊vue項(xiàng)目重構(gòu)技術(shù)要點(diǎn) 這篇文章。

html5和css3實(shí)現(xiàn)展開收起

代碼如下:

<details class="haorooms" open>
 <summary>圖表參數(shù)</summary>
 <content>這里是包含的div等其他展示元素</content>
</details>

css代碼

.haorooms{position:relative}
.haorooms summary{
 -webkit-user-select: none;
 -moz-user-select: none;
 -ms-user-select: none;
 user-select: none;
 outline: 0;
}
/* 自定義的三角 */
.haorooms summary::after {
 content: '';
 position: absolute;
 left:0;
 top:0;
 width: 15px; height: 15px;
 background: url(./haorooms.png) no-repeat; /* 自定義的三角圖片 */
 background-size: 100% 100%;
 transition: transform .2s;
}
.haorooms:not([open]) summary::after {
 transform: rotate(90deg); 
}
/* 隱藏默認(rèn)三角 */
.haorooms ::-webkit-details-marker {
 display: none;
}
.haorooms ::-moz-list-bullet {
 font-size: 0;
}

代碼解釋

html5的detail和summary本身就是一個(gè)展開收起的效果。假如不了解, 可以查看 。

隱藏默認(rèn)三角如下:

.haorooms ::-webkit-details-marker {
 display: none;
}
.haorooms ::-moz-list-bullet {
 font-size: 0;
}

details和summary的ui優(yōu)化

張?chǎng)涡裼衅恼拢瑢?duì)details和summary介紹的很詳細(xì)

對(duì)應(yīng)其UI的優(yōu)化,主要有如下幾個(gè)方面:

1、小三角的優(yōu)化,包括顏色、隱藏、位置、替換。
2、outline輪廓的去除

小三角顏色修改

.haorooms ::-webkit-details-marker {
 color: gray;
}
.haorooms ::-moz-list-bullet {
 color: gray;
}

小三角位置修改-右側(cè)顯示

.haorooms summary {
 width: -moz-fit-content;
 width: fit-content;
 direction: rtl;
}
.haorooms ::-webkit-details-marker {
 direction: ltr;
}
.haorooms ::-moz-list-bullet {
 direction: ltr;
}

outline輪廓的去除

我上面用的是

-webkit-user-select: none;
 -moz-user-select: none;
 -ms-user-select: none;
 user-select: none;
 outline: 0;

這樣對(duì)無障礙訪問非常不友好,優(yōu)化方案可以看張?chǎng)涡翊笊竦淖龇ā?/p>

details和summary其他應(yīng)用

1、更多效果

<details>
 <summary>
 <p>測(cè)試內(nèi)容測(cè)試內(nèi)容</p>
 <div class="more">
 <p>haorooms測(cè)試內(nèi)容測(cè)試內(nèi)容...</p>
 </div>
 <a>更多</a>
 </summary> 
</details>

css代碼

::-webkit-details-marker {
 display: none;
}
::-moz-list-bullet {
 font-size: 0;
 float: left;
}
summary {
 user-select: none;
 outline: 0;
}
.more {
 display: none;
}
[open] .more {
 display: block;
}
[open] summary a {
 font-size: 0;
}
[open] summary a::before {
 content: '收起';
 font-size: 14px;
}

2、懸浮菜單效果

CSS代碼:

/* 隱藏默認(rèn)三角 */
::-webkit-details-marker {
 display: none;
}
::-moz-list-bullet {
 font-size: 0;
 float: left;
}
summary {
 display: inline-block;
 padding: 5px 28px;
 text-indent: -15px;
 user-select: none;
 position: relative;
 z-index: 1;
}
summary::after {
 content: '';
 position: absolute;
 width: 12px; height: 12px;
 margin: 4px 0 0 .5ch;
 background: url(./arrow-on.svg) no-repeat;
 background-size: 100% 100%;
 transition: transform .2s;
}
[open] summary,
summary:hover {
 background-color: #fff;
 box-shadow: inset 1px 0 #ddd, inset -1px 0 #ddd;
}
[open] summary::after {
 transform: rotate(180deg);
}
.box {
 position: absolute;
 border: 1px solid #ddd;
 background-color: #fff;
 min-width: 100px;
 padding: 5px 0;
 margin-top: -1px;
}
.box a {
 display: block;
 padding: 5px 10px;
 color: inherit;
}
.box a:hover {
 background-color: #f0f0f0;
}
.box sup {
 position: absolute;
 color: #cd0000;
 font-size: 12px;
 margin-top: -.25em;
}

HTML代碼:

<div class="bar">
 <details>
 <summary>我的消息</summary> 
 <div class="box">
 <a href>我的回答<sup>12</sup></a>
 <a href>我的私信</a>
 <a href>未評(píng)價(jià)訂單<sup>2</sup></a>
 <a href>我的關(guān)注</a>
 </div>
 </details>
</div>
<p>這里放一段文字表明上面的是懸浮效果。</p>

3、樹形菜單效果

CSS代碼:

/* 隱藏默認(rèn)三角 */
::-webkit-details-marker {
 display: none;
}
::-moz-list-bullet {
 font-size: 0;
 float: left;
}
details {
 padding-left: 20px;
}
summary::before {
 content: '';
 display: inline-block;
 width: 12px; height: 12px;
 border: 1px solid #999;
 background: linear-gradient(to right, #999, #999) no-repeat center, linear-gradient(to top, #999, #999) no-repeat center;
 background-size: 2px 10px, 10px 2px;
 vertical-align: -2px;
 margin-right: 6px;
 margin-left: -20px;
}
[open] > summary::before {
 background: linear-gradient(to right, #999, #999) no-repeat center;
 background-size: 10px 2px;
}

HTML代碼:

<details>
 <summary>我的視頻</summary>
 <details>
 <summary>爆肝工程師的異世界狂想曲</summary>
 <div>tv1-720p.mp4</div>
 <div>tv2-720p.mp4</div>
 ...
 <div>tv10-720p.mp4</div>
 </details>
 <details>
 <summary>七大罪</summary>
 <div>七大罪B站00合集.mp4</div>
 </details>
 <div>珍藏動(dòng)漫網(wǎng)盤地址.txt</div>
 <div>我們的小美好.mp4</div>
</details>

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例

vue和react等項(xiàng)目中更簡(jiǎn)單的實(shí)現(xiàn)展開收起更多等效果示例:前言 本文題目中雖然寫有vue和react,但是并非vue和react相關(guān)知識(shí),而是最基本的html5和css3的一些知識(shí),之所以寫vue,是因?yàn)槲易罱?xiàng)目中用到了類似效果,我用vue相關(guān)知識(shí)實(shí)現(xiàn)并不雅觀,用html5和css3實(shí)現(xiàn),則更加完美。 項(xiàng)目案例 項(xiàng)目中有如下效果: 好
推薦度:
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 欧美日韩国产精品综合 | 国产观看 | 日本欧美国产精品第一页久久 | 日韩中文字幕a | 成人精品一区二区激情 | 亚洲欧美日韩另类精品一区二区三区 | 日韩三级一区二区 | 国产一区二区精品久久91 | 欧美综合自拍亚洲综合 | 99在线视频观看 | 美女一级毛片 | 小说区 亚洲 自拍 另类 | 亚洲日本乱码中文论理在线电影 | 国产成人精品第一区二区 | 欧美xx在线| 国产精品视频福利一区二区 | 亚洲欧洲第一页 | 欧美色图日韩 | 欧美性第一页 | 国产在线视欧美亚综合 | 欧美在线不卡视频 | 麻豆成人在线 | 亚洲国产精品综合久久网络 | 一本久道久久综合 | 日韩亚洲欧美在线爱色 | 成人国产一区二区三区精品 | 99在线视频免费 | 精品一区二区三区四区在线 | 国产香蕉视频 | 久久性色 | 欧美va免费精品高清在线 | 韩国精品一区二区久久 | 欧美成a人片在线观看 | 婷婷爱爱 | 国产美女白丝袜精品_a不卡 | 伊人久久综合 | 久久亚洲精品国产精品婷婷 | 国产成人精品免费视 | 欧美视频三区 | 欧美日韩亚洲国产 | 欧美地区一二三 |