简体   繁体   English

IE字体大小减小不会导致选择框高度减小

[英]IE font size decrease does not cause select box height to decrease

I have a font resize function on my page which increases the font size via javascript for the entire page. 我的页面上有一个字体调整大小功能,该功能通过javascript增加了整个页面的字体大小。

This works fine in most browsers except IE. 在除IE之外的大多数浏览器中,这都可以正常工作。 When decreasing the font size after increasing it, the select boxes new height does not decrease, even though the font size is decreasing on it. 在增加字体大小之后减小字体大小时,即使其上的字体大小减小,选择框的新高度也不会减小。 Instead the smaller font appears to be padded with white space. 而是较小的字体似乎用空白填充。

Any ideas as to what IE is doing here, and a work around? 关于IE在这里做什么以及如何解决的任何想法?

function setFontSize(newFontSize)
   $('select').css("font-size", newFontSize);
}

After IE renders the select box, you cannot change the style of it with javascript (only adding, removing elements, not style or stuff like that). IE渲染选择框后,您将无法使用javascript更改其样式(只能添加,删除元素,不能添加样式或类似的东西)。 That's not a good thing. 那不是好事。

As a work-around what I've done is creating a new select box (clone of the first) with the style that I desire, and then add it as a child of the container tag. 作为解决方法,我要做的是创建一个新的选择框(第一个选择框),该选择框具有所需的样式,然后将其添加为容器标记的子代。 That will display it correctly. 那将正确显示它。

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

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