Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.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 使一个div超过多个div_Html_Position_Center - Fatal编程技术网

Html 使一个div超过多个div

Html 使一个div超过多个div,html,position,center,Html,Position,Center,以下是具有“主干”结构的站点链接: 基本上我需要的是在页面中央放置一个div,高度相同,但宽度为800px。该div需要没有背景。 我试过使用“z-index”,但运气不好 有人能帮忙吗?有些代码会很有用,但我认为您应该使用: position: absolute; 要使用绝对位置将div居中,请使用: left: 50%; margin-left: -400px; //this is because your div's width is 800px 我在您的网站上尝试了以下内容: el

以下是具有“主干”结构的站点链接:

基本上我需要的是在页面中央放置一个div,高度相同,但宽度为800px。该div需要没有背景。 我试过使用“z-index”,但运气不好


有人能帮忙吗?

有些代码会很有用,但我认为您应该使用:

position: absolute;
要使用绝对位置将div居中,请使用:

left: 50%;
margin-left: -400px;  //this is because your div's width is 800px

我在您的网站上尝试了以下内容:

element.style {
    margin-left: auto;
    margin-right: auto;
    width: 800px;
}
这很有帮助


祝你好运

如果您只想将div居中,可以这样做:

#myDiv{
宽度:800px;
左边距:自动;
右边距:自动;
}


但我不确定你是否想让这个部门涵盖你在高层的一些部门。在这种情况下,可以使用
position:relative
然后调整
top
属性。

也可以按如下方式编写:

#yourdiv{
margin: 0px auto;
width:800px;
}

祝你好运

看看是谁首先给你发送了帮助你的答案,然后将其设置为你接受的答案。