为什么 css 'position: absolute' 停止工作了?

Why did css 'position: absolute' stop working?

在我的网站中,我有一个语言栏浮动在屏幕的右上角。

html:

<form id='form2' name='form2' method='get' action=''>
<div id='langs' class='langs'>
<button type='submit' name='lang' value='PT'>PT</button>
<button type='submit' name='lang' value='EN'>EN</button>
</div></form>

css:

.langs {
    background-color: #90A090;
    position:absolute;
    right:4;
    top:4;
}

到目前为止一切顺利。但是当我更新网站以包含来自 here 的登录系统时,出了点问题,语言栏不再浮动。相反,它位于页面末尾。添加的任何文件中都没有 css。 css 的所有其他方面仍然有效(例如更改背景颜色)。该文件以前是 index.php,现在是 main.php(index.php 现在用于登录屏幕)。 css 都在 main.php 文件中。是什么导致行为发生变化?

您缺少值的单位

尝试:

.langs {
    background-color: #90A090;
    position:absolute;
    right:4px; /* right:0; is ok but right:4; will fail */
    top:4px;
}

但是你应该设置相对于父级的位置,以获得更好的结果 xD

form#form2 {
  position: relative;
}