重写CSS计算样式问题(页面布局错误)
我正在重写 CSS(不要问为什么),方式是通过 HTMLElement.setAttribute 方法更改样式属性。当我计算出没有意义的样式时,有时会出现问题。例如(这种情况最常发生),在计算样式中,div 父元素的高度值小于其子 div 元素。这会给所需的页面布局带来一些问题。对我来说改变重写CSS的算法并不容易,实际上非常困难,所以有人知道问题的原因是什么以及解决它的最合适的方法是什么。
我的假设是,某些更改未应用,因此我应该强制 css 解析器重新计算值。有人遇到过这样的问题吗?
I am rewriting CSS (don't ask why) in a way that I'm changing the style attributes via HTMLElement.setAttribute method. The problem sometimes occurs when I have computed styles that make no sense. For example (which happens most frequently), div parent has height value smaller than his child div element, in the computed styles. This makes some problems with the desired layout of the page. It is not easy, actually it is very hard, for me to change the algorithm that rewrites CSS, so does anybody know what is the cause of the problem and what would be the most appropriate way to solve it.
My assumption is that somehow some of the changes are not applied, thus I should force the css parser to recompute the values. Did anybody encounter such problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您仍然尝试以指定的高度显示容器,即使它小于其中的内容,您也应该使用
overflow
属性。overflow:hidden
会导致多余的内容消失。overflow: auto
将为容器添加一个滚动条,以允许您在容器中滚动。Assuming you are still trying to display your container at the height that you specify, even if it is smaller than the content that is inside it, you should use the
overflow
property.overflow: hidden
will cause the extra content to disappear.overflow: auto
will add a scrollbar to the container to allow you to scroll in the container.