繁体   English   中英

CSS Height:无法增加父类的高度?

[英]CSS Height : Unable to increase the height of parent class?

我面前的一个有趣的问题。 我有

<div class="box-content">
    <p style="height: inherit; width: inherit;">
        <iframe width="100%" height=" 100%" src="http://localhost/imagebase/image/data/banner/swf/Comp1.swf"></iframe>
    </p>
</div>

我还需要使此代码与移动设备兼容。 我所看到的是,如果我固定p的大小,那么众所周知,它在移动设备上的大小相同。 但在inherit情况下,它采用其父div的宽度,该宽度与移动设备兼容。

但是我无法达到全高,因为它没有那个高度。 默认情况下,它的185px ,我必须具有300px的宽度才能显示我的swf文件。

是否有任何方法可以按照此piframe建议在JavaScrip或jQuery中自动更改此框内容类的高度。

我不能直接更改此类的高度,因为它在很多地方都在使用。

编辑

正如Brett所建议的那样,如果您出于某种原因无法更改html,则可以使用以下css规则:

.box-content p {
    min-height: 300px;
}

但是 ,下面的示例显示了它可能/应该是什么样子。

我还将内联样式移动到css规则,这使以后更改行为变得更加容易,并且作为容器最合适的标记是div ,而不是p

 .swf-container { height: 100%; width: 100%; min-height: 300px; } .swf-container iframe { height: 100%; width: 100%; } 
 <div class="box-content"> <div class="swf-container"> <iframe src="http://localhost/imagebase/image/data/banner/swf/Comp1.swf"></iframe> </div> </div> 

暂无
暂无

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

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