gpt4 book ai didi

javascript - 为什么在 onBeforeDeactivate 事件处理程序中调用 focus() 时 DIV 会移动?

转载 作者:行者123 更新时间:2023-11-28 00:31:09 25 4
gpt4 key购买 nike

我在 IE7/8 中遇到一个网页有线问题。配置为 dir="rtl" 的页面。并且 divRow 做得非常大 width 所以它包含的 div 不会换行。

单击编辑器区域,键入一些单词,然后单击“Hello world”文本。由于divRow 类的div 的偏移量和宽度发生了变化,布局将变得凌乱。

我想这是一个 IE7/8 错误。有什么办法可以解决这个问题吗?

基本上,divRow 必须使其包含的 div 不换行。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style>
div
{
border: 1px;
border-color: black;
}

.divRow
{
/* this is to make its containing div not to wrap */
min-width: 2000px;
}

div.divEditor
{
width: 100%;
}

iframe
{
height: 100%;
width: 100%;
}
</style>
<script>
function $(id)
{
return document.getElementById(id);
}

function focusToRight()
{
var elem = $("innerDiv1");

function fcs()
{
elem.focus();
}
setTimeout(fcs, 1);

}
</script>
</head>
<body dir="rtl">
<div>
<div id='main'
style="overflow: hidden; position: relative; width=100%">
<div class="divRow" id="firstRow">
<div style='float:right' id='innerDiv1'>
Hello world.
</div>
<div style='float:right' id='innerDiv2'>
This is to make it is very very very very very very very very
very very very very very very very very long
</div>
</div>
<div class="divEditor">
<iframe id="editorIFrame" onbeforedeactivate="focusToRight();"
src="about:blank"></iframe>
</div>
</div>

</div>
<script>
//document.getElementById('main').style.width='40px';
//$("editorIFrame").document.designMode = "on";
document.frames["editorIFrame"].document.designMode = "On";
</script>
</body>
</html>

最佳答案

完全摆脱 min-width:2000px 条件。

阻止包含的 div 环绕或折叠的方法是在它的末尾之前插入一个带有 style="clear:right"的空 div。这个新的 div 仍在包含的 div 中,但它必须清除 float ,即低于 float ,因此它会拉伸(stretch) div 的垂直高度。

关于javascript - 为什么在 onBeforeDeactivate 事件处理程序中调用 focus() 时 DIV 会移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/742975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com