如何隐藏父div,保持内部div可见? [英] how to hide parent div, keeping inner div visible?

查看:139
本文介绍了如何隐藏父div,保持内部div可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的问题的简化版本。考虑下面的一段HTML代码:

 < div id =div1style =display:none> 
文字我不希望
< div id =div2style =display:block>
text我想保留
< / div>
< / div>

但当然,我想保留的文本不会是显示是因为
父div不可见。

问题:你如何显示内部div的内容?

由于小部件博客使用,我无法访问代码,需要用一些CSS清除外部div。在阅读 font-size:0; rel =nofollow noreferrer>这个。由于元素的位置,排除负边界的消除也被排除。

解决方案

试试这个:

  color:transparent; 
背景:透明;

当然,这实际上并不会使文本不可选,只是不可见。 / p>

真的你想要做的是对付盒子模型的概念,如果你能够附上你没有看到的文字想要在与你想要看到的水平相同的水平上看到一个单独的div,然后隐藏另一个div,即

 < div id =div1> 
< div id =div3style =display:none> text我不想要< / div>
< div id =div2style =display:block>
text我想保留
< / div>
< / div>


Below is a simplified version of my problem. Considering the following piece of HTML:

<div id="div1" style="display:none">  
  text i do not want  
  <div id="div2" style="display:block">  
    text i want to keep  
  </div>  
</div>  

But of course, "text i want to keep" will not be displayed because the parent div is not visible.

Question: How do you only dispaly the content of the inner div?

Due to the widget blogger uses, I have no access to the code and need to clear the outer div with some CSS. I have already ruled out font-size: 0; after reading this. Messing with negative margins too is ruled out, due to position of elements.

解决方案

try this:

color: transparent;
background: transparent;

of course, that won't actually make the text non-selectable, just non-visible.

Really what you're trying to do is sort of against the box-model concept, and it'd be better if you were able to enclose the text you didn't want to see in a separate div of equal level to the one you do want to see, and then hide that other div, i.e.

<div id="div1">  
  <div id="div3" style="display:none">text i do not want</div>
  <div id="div2" style="display:block">  
    text i want to keep  
  </div>  
</div>

这篇关于如何隐藏父div,保持内部div可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆