[英]How to set display none on <a> tag using css?
我希望我的類別框僅顯示子類別
喜歡
main category
subcategory 1
subcategory 1_1
subcategory 1_2
subcategory 1_3
subcategory 2
subcategory 2_1
subcategory 2_2
subcategory 3
subcategory 4
我想這樣顯示
subcategory 1
subcategory 2
subcategory 3
subcategory 4
這是我的HTML代碼,我使用CSS隱藏父類別,但我不知道如何隱藏“ 草本產品”下的“ 品牌和濃縮粉 ” 商店
<div class="sideBoxContent" id="categoriesContent">
<a href="index.php?main_page=index&cPath=2" class="category-top">
<span class="category-subs-parent">Product</span>
</a>
<br>
<a href="index.php?main_page=index&cPath=2_4" class="category-subs"> Accupuncher Niddels
</a>
<br>
<a href="index.php?main_page=index&cPath=2_7" class="category-subs">
<span class="category-subs-parent"> Herbal Products</span>
</a>
<br>
<a href="index.php?main_page=index&cPath=2_7_9" class="category-products"> Concentrated Powders
</a>
<br>
<a href="index.php?main_page=index&cPath=2_7_8" class="category-products"> Shop by Brand
</a>
<br>
<a href="index.php?main_page=index&cPath=2_10" class="category-products"> Magnets, Pellets & Tapes
</a>
<br>
<a href="index.php?main_page=index&cPath=2_3" class="category-products"> New Arrival
</a>
<br>
<hr id="catBoxDivider">
</div>
我的CSS像這樣
A.category-subs, A.category-subs:visited {
color: #FF0000;
text-decoration: none;
}
A.category-products, A.category-products:visited
{
display: none;
}
但是我沒有得到正確的輸出,因為它隱藏了所有類別產品,並且我希望它僅隱藏如我上面提到的兩個
提前致謝
這是禪車嗎? 如果是這樣,我自己經歷了一個類似的問題,便創建了一個新的類別菜單,其中子貓出現在懸停菜單上。 我用彈出類別菜單(附加模塊- http://www.zen-cart.com/downloads.php?do=file&id=1290 )根據意見提出,其產生的類別subcats作為嵌套UL,這是禪購物車1.5,但舊版本也有類似的功能。 如果刪除javascript,則該腳本無需動畫即可正常工作,並且您可以輕松隱藏所需的元素。
我可以想到的使用HTML的唯一方法是使用一些jquery,然后可以選擇某個元素並將其隱藏。 例如
$("#categoriesContent a:nth-child(4)").css('display','none');
隱藏濃縮粉。 但這顯然會出錯,如果您添加類別,則會更改元素的索引。 我想您可以通過使用.each()遍歷a元素來解決這個問題,並使用a.link(.html)的鏈接獲取其內容以將其與特定字符串進行比較,例如“濃縮粉”,但這會得到復雜,更改html會容易得多。 簡而言之,我認為您需要重新考慮您的方法,並檢查高級類別mod或編輯當前的categoies模板文件,您可以在include / templates / default_template / sideboxes / tpl_categories.php中找到該模板文件,並將其復制到模板目錄並進行編輯-詢問另一個問您是否需要幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.