gpt4 book ai didi

html - CSS 边距问题

转载 作者:太空宇宙 更新时间:2023-11-03 21:00:02 24 4
gpt4 key购买 nike

编辑:我的问题不清楚,所以这只是为了澄清。

20 像素的左边距将 div 总共移动了 20 像素,但输入控件似乎总共移动了 40 像素。

原始问题:

下面的脚本是整个脚本,下面的脚本没有附加其他脚本/样式:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<body>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 0px;border:1px black solid;">
<input type="text"/>
</div>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 0px;border:1px black solid;">
<input type="text" />
</div>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 0px;border:1px black solid;">
<input type="text" />
</div>
</body>
</html>

出于某种原因,当我在任何这些 div 标签的左侧添加 20px 边距时,出于某种原因,它不仅将所有 div 向右移动 20px,而且还将 div 标签内的输入字段移动 20px在 div 标签内的右侧。

例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<body>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 20px;border:1px black solid;">
<input type="text"/>
</div>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 0px;border:1px black solid;">
<input type="text" />
</div>
<div style="float:left;width:300px;height:400px;margin:0px 0px 0px 0px;border:1px black solid;">
<input type="text" />
</div>
</body>
</html>

为什么会这样?

我正在使用 Internet Explorer 7 模式在 Internet Explorer 8 中进行测试。我已经在 Internet Explorer 8 中使用标准的 Internet Explorer 8 模式对其进行了测试,它运行良好。

最佳答案

这看起来像是双 float 边距错误的奇怪表现。将 display: inline 放在第一个 divstyle 属性中将阻止旧版本 IE 中的边距加倍。

但是,正如其他人所说,我会创建类。它使事情更整洁。

关于html - CSS 边距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4851886/

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