|
之前不會用選項卡代碼,搞了4個單頁組合在一起,今天找了代碼,又研究了一下,基本實現了一個頁面選項卡應用。
截圖202302021452226215.jpg (16.26 KB, 下載次數: 21)
下載附件
2023-2-2 14:52 上傳
但是現在有一個問題,如明星等其他選項卡內容也會有翻頁,點擊是默認頁面的翻頁(明星等其他內容是寫死內容的),我現在想讓明星等選項卡內容隱藏翻頁代碼。
截圖202302021453512834.jpg (8.18 KB, 下載次數: 15)
下載附件
2023-2-2 14:53 上傳
選項卡div代碼
- <div class="nav1">
- <div class="active">默認</div>
- <div class="">明星</div>
- <div class="">推書</div>
- <div class="">TXT</div>
- </div>
- <!--選項卡start-->
- <div class="taglist">
- <div class="list">
- <div>
- <ul class="cl">
- <!--{loop $tagarray $tag}-->
- <li class="{echo $yide_color[array_rand($yide_color,1)];}">
- <a href="tag-$tag[tagid].html">$tag[tagname]</a>
- </li>
-
- <!--{/loop}-->
-
- </ul>
-
- </div>
- <div><ul class="cl">
- <!--{block/189}-->
- </ul></div>
- <div>
-
- <ul class="cl">
- <!--{block/190}-->
- </ul>
-
- </div>
- <div><ul class="cl">
- <!--{block/192}-->
- </ul></div>
- </div>
- </div>
復制代碼
翻頁相關代碼
- <div class="tag-pg" style="margin:20px 0 10px 0" >{$pageStyle}</div>
- <!--{else}-->
- <div class="zz_no_content cl">
- <i class="iconfont icon-zanwuneirong-"></i>
- <p>{lang no_tag}</p>
- </div>
復制代碼
選項卡相關CSS
- .bg {
- background: #fff;
- }
- .taglist{padding: 10px 15px;
- line-height: 13px;
- font-size: 13px;
- background: #fff;
- }
- .nav1{
- width: 100%;
- height: 50px;
- display: flex;
- background-color: #fff;
- }
- .nav1 div{
- width: 30px;
- height: 42px;
- line-height: 50px;
- text-align: center;
- font-size: 14px;
- margin: 0 0 0 30px;
- }
-
- .list{
- width: 98%;
- margin-left: 2%;
- padding: 10px 0 0 0;
- }
- .list div{
- width: 100%;
- height: 100%;
- }
- .active{
- background-color: #fff;
- color: #333;
- font-size: 14px;
- border-bottom: 2.5px solid #59d192;
- }
復制代碼
選項卡JS代碼
- <script type="text/javascript">
-
- let nav = document.getElementsByClassName('nav1')[0];
- let but = nav.getElementsByTagName('div');
-
- let list = document.getElementsByClassName('list')[0];
- let item = list.getElementsByTagName('div');
-
- // 隱藏多余選項列表
- for(let i = 1; i < item.length; i++){
- item[i].style.display = "none";
- }
-
- // 循環按鈕綁定事件
- for(let k = 0; k < but.length; k++){
- but[k].onclick = function(){
-
- for(let j = 0; j < but.length; j++){
- but[j].className = "";
- item[j].style.display = "none";
- }
- but[k].className = "active";
- item[k].style.display = "block";
- }
- }
- console.log(item)
- </script>
復制代碼
最后附上tag頁面的文件以及地址:https://www.honghuangwenxue.com/misc.php?mod=tag
選項卡.rar
(1.62 KB, 下載次數: 95)
2023-2-2 14:58 上傳
點擊文件名下載附件
我知道答案
回答被采納將會獲得 1 貢獻 已有1人回答
|
|