Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在所有浏览器中平等地定位表单元素,而不考虑窗口大小。_Html_Css - Fatal编程技术网

Html 如何在所有浏览器中平等地定位表单元素,而不考虑窗口大小。

Html 如何在所有浏览器中平等地定位表单元素,而不考虑窗口大小。,html,css,Html,Css,这是我的表格代码: <td align="center" style=" width=50%; height=50%; background: url(images/side.gif) repeat-x ;"> <img src="images/iphone.gif" width="670" height="549" alt=""> <img style="position:fixed; left:280px; bottom:50px;"src="spr2.png"

这是我的表格代码:

<td align="center" style=" width=50%; height=50%; background: url(images/side.gif) repeat-x ;">
<img src="images/iphone.gif" width="670" height="549" alt="">
<img style="position:fixed; left:280px; bottom:50px;"src="spr2.png" width="2%" height="15%" alt="">
<form style="display:inline-block;" method="POST" action="index.php">
<label style="position:fixed; left: 200px; bottom: 130px;">: اسم المستخدم</label>
<input style="position:fixed; left:50px; bottom:130px;" type="text" name="username" size="20"><br>
<label style="position:fixed; left:200px; bottom:100px;">: كلمة المرور</label>
<input style="position:fixed; left:50px; bottom:100px;" type="password" name="password" size="20"><br>
<input style="position:fixed; left:50px; bottom:60px;" type="submit" value=" تسجيل دخول ">
</form>
</td>

: اسم المستخدم

: كلمة المرور
以下是来自不同浏览器的屏幕截图:

调整窗口大小时,元素的位置会发生变化:


如何防止元素改变位置和宽度?

对于宽度问题,请尝试使用
宽度,如中所示


您的
位置问题可能源于您正在使用
的值fixed
。相对定位的内部可能更像您要做的。

您在页面上定位元素的方式忽略了相对定位的正常流程。通过指定
left:200px
位置:固定您的意思是,无论页面大小如何调整,或者滚动到何处,元素在窗口左侧的位置始终为200px。请注意,即使文本框后面有

标记,标签仍然直接位于文本框的右侧

使用相对定位-
位置:相对或仅删除位置属性。然后使用填充和边距隔开元素,或使它们浮动。如果它们没有水平显示在一行中,则将
显示
属性更改为
内联块
,并在标签上使用
清除:右或在其后面放置一个

将您的样式放入和外部文件中


类似这样:

为什么不通过css声明输入元素的宽度?请举例说明,因为我是html/CST的初学者谢谢,宽度问题已经解决了。但即使我将fixed改为absolute,位置仍然存在。父元素是否设置为
relative
positioning?父元素是TD元素,他的所有样式似乎都是内联的。@jmeas我将其设置为relative,但要定位输入元素,我必须使用减号。对狩猎和歌剧很好,但对Firefox很差谢谢你的解释,但我真的不明白。
<input type="text" style="width:200px;" size="20">
<input type="text" style="width:200px;" size="40">​