jQuery CSS 渲染 - 适用于 Firefox,不适用于 Chrome

发布于 2024-12-27 20:46:42 字数 312 浏览 3 评论 0原文

我使用 jQuery 滑块来调整包含段落文本的 DIV 的填充。当我均匀地增加所有边的填充时,它应该迫使所包含的段落进入页面中心的越来越窄的列。

这在 Firefox 中有效,但在 Chrome 中,段落宽度保持不变(即,当 DIV 的填充推入它们时,它们不会变窄),因此将布局推到右侧。

我在这里重新创建了该问题:jsfiddle.net/ms3Jd。您可以在 Chrome 和 Firefox 中尝试一下,看看有什么不同。

关于如何强制 Chrome 刷新所附段落有什么想法吗?

I'm using a jQuery slider to adjust the padding of a DIV containing paragraph text. As I increase the padding on all sides equally, it should force the enclosed paragraphs into an ever-narrower column, in the center of the page.

This works in Firefox, but in Chrome the paragraph widths remain constant (i.e. they don't become narrower as the DIV's padding pushes in on them), so pushing the layout to the right.

I've recreated the issue here: jsfiddle.net/ms3Jd. You can try it in Chrome and Firefox to see the difference.

Any ideas on how to force Chrome to refresh the enclosed paragraphs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

等风来 2025-01-03 20:46:42

我知道有一些方法可以强制(或欺骗)Chrome
刷新/重绘/重新计算页面元素,但不知道该怎么做
它。有什么想法吗?

摘自此处:我如何强制WebKit 重绘/重绘以传播样式更改?

sel.style.display='none';
sel.offsetHeight; // no need to store this anywhere, the reference is enough
sel.style.display='block';

我在这里快速应用了它,但您应该将其变成一个函数:http://jsfiddle.net/thirtydot/ms3Jd/5/

I know there are ways to force (or trick) Chrome to
refresh/redraw/recalcuate the page elements, but don't know how to do
it. Any ideas?

Taken from here: How can I force WebKit to redraw/repaint to propagate style changes?

sel.style.display='none';
sel.offsetHeight; // no need to store this anywhere, the reference is enough
sel.style.display='block';

I quickly applied it here, but you should make it into a function: http://jsfiddle.net/thirtydot/ms3Jd/5/

莫相离 2025-01-03 20:46:42

我正在使用 fadeTo 强制 chrome 刷新。
不确定,但我猜是 fadeTo 上的动画起到了作用
jsfiddle 上尝试该行。

$('#preview > div').css('padding', ui.value + '%' ).children('p').fadeTo(1, .99).fadeTo(1, 1);

I'm using fadeTo to force chrome to refresh.
Not sure but I guess it's the animate on fadeTo that does the trick
try that line on jsfiddle.

$('#preview > div').css('padding', ui.value + '%' ).children('p').fadeTo(1, .99).fadeTo(1, 1);
浅忆 2025-01-03 20:46:42

您可以添加溢出和浮动属性:

#preview > div {
    padding: 5%;
    overflow: auto;
    float: left;
}

You can add the overflow and float properties:

#preview > div {
    padding: 5%;
    overflow: auto;
    float: left;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文