【发布时间】:2015-07-05 18:40:56
【问题描述】:
我不太了解 jQuery,所以我不知道如何添加 CSS 内联。 这是我的代码:
<div class="gm-style-iw" style="top: 9px; position: absolute; left: 15px; width: 23px;">
<div style="display: inline-block; overflow: hidden; max-height: 330px; max-width: 176px;">
<div style="overflow: auto">
<div id="iw-container">
</div>
</div>
</div>
</div>
我想更改第二个div的max-width,并将overflow: none添加到#iw-container上方的div中。
我试过了,但没用:
var iwOuter = $('.gm-style-iw');
iwOuter.children().css({max-width:'250px !important'});
iwOuter.children().children().css({overflow:'none'});
编辑我想自定义 infowindow Google,对我来说改变 max-width 和 overflow 的值很重要......我认为你的代码可能很好,但我不明白为什么不起作用...
【问题讨论】:
-
必须是 'max-width': '250px !important'
-
虽然它与您的具体问题并不真正相关,但我绝对建议您learn how to work with CSS Stylesheets instead of inline-css。这样你就可以使用classes(这使得change css with jQuery更容易)。你也应该avoid using
!importantin your CSS,因为它通常会造成比它解决的更多的麻烦。