Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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 Internet Explorer中的Div相对定位问题_Html_Css - Fatal编程技术网

Html Internet Explorer中的Div相对定位问题

Html Internet Explorer中的Div相对定位问题,html,css,Html,Css,HTML: <div id="broadcast"> <div id="broadcast_header"> Neighbourhood Broadcast </div> </div> Firefox:一切正常,标题显示在div上方20px,很酷。 IE:拒绝显示div(广播标题) 溢出:可见 doctype定义:给定 我的输入:假设将top更改为-top:-5px部分显示div(标题)。 谢谢你:。在你的CSS中

HTML:

<div id="broadcast">
    <div id="broadcast_header">
        Neighbourhood Broadcast
    </div>
</div>
Firefox:一切正常,标题显示在div上方20px,很酷。
IE:拒绝显示
div(广播标题)

溢出:可见
doctype
定义:给定

我的输入:假设将top更改为-
top:-5px部分显示div(标题)。

谢谢你:。

在你的CSS中添加
正文{margin:0}

效果不同。周围元素(#广播)必须具有位置:相对;所有物然后您可以使用position:absolute来定位(#broadcast_header)相对于这个位置

#broadcast_header
{
    background-color: #A0522D;
    width: 100%;
    height: 20px;
    position: absolute;
    top: -20px;
    font-weight: bold;
}

#broadcast
{
     position: relative;
}

请更改您的标题,尽管这可能是真的,但不要“转到”网站。广播已经是静态的,这允许其子项四处移动。此外,绝对定位会对布局的灵活性产生负面(不必要)影响。问题在哪里提到“广播是静态的?”?
#broadcast_header
{
    background-color: #A0522D;
    width: 100%;
    height: 20px;
    position: absolute;
    top: -20px;
    font-weight: bold;
}

#broadcast
{
     position: relative;
}