简体   繁体   English

如何<a>使用CSS</a>在<a>标签上</a>不显示任何内容<a>?</a>

[英]How to set display none on <a> tag using css?

I want that my categorybox display only subcategory 我希望我的类别框仅显示子类别

like 喜欢

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

I want to display like this 我想这样显示

subcategory 1
subcategory 2
subcategory 3
subcategory 4

This is my HTML code and i am hide the parent category using css but i am not understood how can i hide the Shop by Brand and Concentrated Powders under Herbal Products 这是我的HTML代码,我使用CSS隐藏父类别,但我不知道如何隐藏“ 草本产品”下的“ 品牌浓缩粉商店

<div class="sideBoxContent" id="categoriesContent">
       <a href="index.php?main_page=index&amp;cPath=2" class="category-top">
             <span class="category-subs-parent">Product</span>
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_4" class="category-subs">&nbsp;&nbsp;Accupuncher Niddels 
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_7" class="category-subs">
            <span class="category-subs-parent">&nbsp;&nbsp;Herbal Products</span>
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_7_9" class="category-products">&nbsp;&nbsp;&nbsp;&nbsp;Concentrated Powders
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_7_8" class="category-products">&nbsp;&nbsp;&nbsp;&nbsp;Shop by Brand
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_10" class="category-products">&nbsp;&nbsp;Magnets, Pellets &amp; Tapes
       </a>
       <br>
       <a href="index.php?main_page=index&amp;cPath=2_3" class="category-products">&nbsp;&nbsp;New Arrival
       </a>
       <br>
<hr id="catBoxDivider">
</div>

My css like this 我的CSS像这样

A.category-subs, A.category-subs:visited {

    color: #FF0000;

    text-decoration: none;

    }

    A.category-products, A.category-products:visited
    {
        display: none;
    }

but i am not get proper out put because it hide all the category-products and i want that it just hide only two as i mention above 但是我没有得到正确的输出,因为它隐藏了所有类别产品,并且我希望它仅隐藏如我上面提到的两个

Thanks in advance 提前致谢

Is this zen cart? 这是禅车吗? If so i have just been through a similar issue myself creating a new categories menu where subcats appear on hover. 如果是这样,我自己经历了一个类似的问题,便创建了一个新的类别菜单,其中子猫出现在悬停菜单上。 I used the flyout categories menu (additional module - http://www.zen-cart.com/downloads.php?do=file&id=1290 ) which generates the categories subcats as a nested ul as suggested in comments, this is for zen cart 1.5 but similar things are available for older versions. 我用弹出类别菜单(附加模块- http://www.zen-cart.com/downloads.php?do=file&id=1290 )根据意见提出,其产生的类别subcats作为嵌套UL,这是禅购物车1.5,但旧版本也有类似的功能。 if you delete the javascript, this one will work fine without animation and you can easily hide the elements you want to. 如果删除javascript,则该脚本无需动画即可正常工作,并且您可以轻松隐藏所需的元素。

The only way I can think of to do it with the html you have is to use some jquery, you could then select a certain element and hide them that way. 我可以想到的使用HTML的唯一方法是使用一些jquery,然后可以选择某个元素并将其隐藏。 for example 例如

$("#categoriesContent a:nth-child(4)").css('display','none');

to hide concentrated powders. 隐藏浓缩粉。 But this would obviously go wrong if you added a category as the index of the elements would be altered. 但这显然会出错,如果您添加类别,则会更改元素的索引。 I suppose you could get round this instead by looping through the a elements with .each(), get their content with .html() of the a links to compare it to a particular string, eg, 'Concentrated powders' but this would get complicated and it would be much easier to change the html. 我想您可以通过使用.each()遍历a元素来解决这个问题,并使用a.link(.html)的链接获取其内容以将其与特定字符串进行比较,例如“浓缩粉”,但这会得到复杂,更改html会容易得多。 In short I think you need to rethink your approach and check out the advanced categories mod or edit the current categoies template file which you will find in includes/templates/default_template/sideboxes/tpl_categories.php copy to your template directory and edit - ask another question if you need help with that. 简而言之,我认为您需要重新考虑您的方法,并检查高级类别mod或编辑当前的categoies模板文件,您可以在include / templates / default_template / sideboxes / tpl_categories.php中找到该模板文件,并将其复制到模板目录并进行编辑-询问另一个问您是否需要帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM