简体   繁体   English

为什么 [hidden] 属性和“显示:无样式”不适用于我的<div>在 Angular html 组件中包含 SVG 标签的标签?

[英]Why is the [hidden] attribute and 'display: none style' not working on my <div> tag containing an SVG tag in Angular html Component?

I'm trying to hide my svg tag using the parent div tag, but it doesn't seem to be hiding either the read more div or the svg tag within it, using either the [hidden]--attribute, or bootstrap 'd-none' or css display:none;我正在尝试使用父 div 标签隐藏我的 svg 标签,但它似乎没有隐藏read more div 或其中的svg 标签,使用 [hidden]--attribute 或 bootstrap 'd -none' 或 css display:none;

<div  class="d-flex" [hidden]="true">
<div class="read-more mr-2">read more</div>
        <svg class="icon icon-read_more align-self-center bg-light">
          <use xlink:href="assets/symbol-defs.svg#icon-read_more"></use>
        </svg>
</div>

or或者

  <div  class="d-flex d-none">
    <div class="read-more mr-2">read more</div>
            <svg class="icon icon-read_more align-self-center bg-light">
              <use xlink:href="assets/symbol-defs.svg#icon-read_more"></use>
            </svg>
    </div>

Proper way should be:正确的方法应该是:

<div class="d-flex" hidden>
   <!-- inner div content -->
</div>

Another option would be to use the visibility attribute:另一种选择是使用visibility属性:

visibility: visible; versus visibility: hidden;visibility: hidden;

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

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