IE font size decrease does not cause select box height to decrease

末鹿安然 提交于 2019-12-11 14:12:58

问题


I have a font resize function on my page which increases the font size via javascript for the entire page.

This works fine in most browsers except 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?

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

回答1:


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). 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.



来源:https://stackoverflow.com/questions/2463226/ie-font-size-decrease-does-not-cause-select-box-height-to-decrease

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!