繁体   English   中英

即使我的CSS已将JQuery Mobile OSM div的高度自动设置为0%,

[英]JQuery Mobile OSM div is set to 0% height automatically even though my CSS has it set to 100%

我在JQuery Mobile应用程序中使用Open Street Maps。 该地图位于其自己的页面上,并在用户单击指向页面的链接时显示。 地图代码有效,但是当我在CSS中具有100%时,地图所在的div自动设置为height:0%。 我可以使用chrome中的inspect元素将div的高度手动更改为100%,地图会正确显示。 (此外,在点击链接后,地图会闪烁一会儿,然后消失,因此由于某种原因,在点击链接后,某些东西会迫使其恢复为0%)

编辑:我尝试使用!important,但没有用。

您可以这样使用!important

height: 100% !important

为什么我的<div>不会自动设置它的高度?</div><div id="text_translate"><p> 我有一个 HTML 结构如下所示:</p><pre> &lt;div class="act"&gt; &lt;div&gt;/*left button*/&lt;/div&gt; &lt;div&gt; &lt;p&gt;My very long text goes here&lt;/p&gt; &lt;/div&gt; &lt;div&gt;/*right button*/&lt;/div&gt; &lt;/div&gt;</pre><p> 我的外部 div 有一个min-height ,但我没有设置它的height ,以便它适合它里面的任何东西。 &lt;p&gt;有短文本时看起来很好,但如果我在&lt;p&gt;内放置长文本,文本会溢出外部&lt;p&gt;之外。</p><p> 这是我的 css (sass) 文件</p><pre>@mixin flexCenter($direction) { display: flex; justify-content: center; align-items: center; flex-direction: $direction; }.act { @include flexCenter(row); width: 100%; min-height: 2rem; border-radius: 2px; margin-top: 1rem; justify-content: space-between; box-shadow: 0px 3px 4px -1px rgba(0,0,0,0.48); padding: .5rem; cursor: pointer; div { height: 100%; width: 1.35rem; height: 2.35rem; border-radius: 2px; @include flexCenter(row); &amp;:nth-child(2) { background: inherit; width: 100%; text-align: center; p { font-size: .9rem; } } } }</pre><p> 我想不通,也许有人可以帮助我吗? 谢谢</p></div>

[英]Why does my <div> does not automatically set its height?

暂无
暂无

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

相关问题 100%Height Div与jQuery和CSS jQuery或CSS:为div设置静态的,不可更改的高度? jQuery设置di​​v高度 jQuery mobile将我的屏幕尺寸设置为100% 为什么我的<div>不会自动设置它的高度?</div><div id="text_translate"><p> 我有一个 HTML 结构如下所示:</p><pre> &lt;div class="act"&gt; &lt;div&gt;/*left button*/&lt;/div&gt; &lt;div&gt; &lt;p&gt;My very long text goes here&lt;/p&gt; &lt;/div&gt; &lt;div&gt;/*right button*/&lt;/div&gt; &lt;/div&gt;</pre><p> 我的外部 div 有一个min-height ,但我没有设置它的height ,以便它适合它里面的任何东西。 &lt;p&gt;有短文本时看起来很好,但如果我在&lt;p&gt;内放置长文本,文本会溢出外部&lt;p&gt;之外。</p><p> 这是我的 css (sass) 文件</p><pre>@mixin flexCenter($direction) { display: flex; justify-content: center; align-items: center; flex-direction: $direction; }.act { @include flexCenter(row); width: 100%; min-height: 2rem; border-radius: 2px; margin-top: 1rem; justify-content: space-between; box-shadow: 0px 3px 4px -1px rgba(0,0,0,0.48); padding: .5rem; cursor: pointer; div { height: 100%; width: 1.35rem; height: 2.35rem; border-radius: 2px; @include flexCenter(row); &amp;:nth-child(2) { background: inherit; width: 100%; text-align: center; p { font-size: .9rem; } } } }</pre><p> 我想不通,也许有人可以帮助我吗? 谢谢</p></div> 在 CSS 中将 Div 宽度设置为 100% 会破坏脚本的宽度 移动设备上的100%高度和CSS jquery找到img大小并设置为div css的高度和宽度 自动为绝对孩子的父div设置高度 如何自动设置DIV元素的高度
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM