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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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置于其他div之上_Html_Css_Css Position - Fatal编程技术网

Html 如何将div div置于其他div之上

Html 如何将div div置于其他div之上,html,css,css-position,Html,Css,Css Position,我试着把div的位置设置成这样: 但我无法将图像(绿色框)设置到位 橙色的盒子在上面 蓝色和浅绿色div是按钮 红色框在橙色框下静止 绿色框与内部图像链接,部分覆盖蓝色和浅绿色按钮 每个链接必须保持每次点击 我无法将绿色图像居中,并将其部分设置在橙色div上方 示例代码 我已经上传了你的JSFIDLE 添加了以下css: .header-image { position: absolute; top: 40px; left: 20%; } 还为.menu容器 .m

我试着把div的位置设置成这样:

但我无法将图像(绿色框)设置到位

  • 橙色的盒子在上面
  • 蓝色和浅绿色div是按钮
  • 红色框在橙色框下静止
  • 绿色框与内部图像链接,部分覆盖蓝色和浅绿色按钮
  • 每个链接必须保持每次点击
我无法将绿色图像居中,并将其部分设置在橙色div上方

示例代码


我已经上传了你的JSFIDLE

添加了以下css:

.header-image {
    position: absolute;
    top: 40px;
    left: 20%;
}
还为
.menu容器

.menu-container {
    margin-top: 80px; //instead of 50px
}

我将它定位为绝对位置,因为这样,它将根据身体相对位置去任何你想去的地方。

我已经上传了你的JSFIDLE

添加了以下css:

.header-image {
    position: absolute;
    top: 40px;
    left: 20%;
}
还为
.menu容器

.menu-container {
    margin-top: 80px; //instead of 50px
}

我将它定位为绝对位置,因为这样,它将根据身体相对位置去任何你想去的地方。

我已经上传了你的JSFIDLE

添加了以下css:

.header-image {
    position: absolute;
    top: 40px;
    left: 20%;
}
还为
.menu容器

.menu-container {
    margin-top: 80px; //instead of 50px
}

我将它定位为绝对位置,因为这样,它将根据身体相对位置去任何你想去的地方。

我已经上传了你的JSFIDLE

添加了以下css:

.header-image {
    position: absolute;
    top: 40px;
    left: 20%;
}
还为
.menu容器

.menu-container {
    margin-top: 80px; //instead of 50px
}

我将其定位为绝对位置,因为这样,它将根据身体相对位置移动到任何你想要的地方。

将此添加到
图像中
应该可以:

margin:0 auto;
position:relatve;
z-index:66;
margin-top:-10px

将此添加到
图像中应该可以:

margin:0 auto;
position:relatve;
z-index:66;
margin-top:-10px

将此添加到
图像中应该可以:

margin:0 auto;
position:relatve;
z-index:66;
margin-top:-10px

将此添加到
图像中应该可以:

margin:0 auto;
position:relatve;
z-index:66;
margin-top:-10px
试试看

只更改了css

body,html{margin: 10px;}
.header-container{
    width: 100%;
}
a{
    text-decoration:none;
    color:#000;
    padding: 10px 0px;
    display: block;
    text-align: center;
}
.nav-container{
    width: 100%;
    height: 50px;
    background: orange;
}
.logo{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightblue;
    float: left;
}
.nav{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightgreen;
    float: right;
}
.header-image{
    width: 100%;
    border: 1px solid green;
    position: relative;
    z-index: 2;
    text-align: center;
}
.image{
    height: 100px;
    width: 60%;
    margin: 0 auto;
    margin-top: -20px;
    background: green;
    opacity: 0.6;
}
.header-image a{
    padding: 40px 0;
}
.menu-container{
    width: 100%;
    border: 1px red solid;
    height: 40px;
    margin-top: 50px;
}
只需将其添加到图像类:

margin: 0 auto;
margin-top: -20px;
试一试

只更改了css

body,html{margin: 10px;}
.header-container{
    width: 100%;
}
a{
    text-decoration:none;
    color:#000;
    padding: 10px 0px;
    display: block;
    text-align: center;
}
.nav-container{
    width: 100%;
    height: 50px;
    background: orange;
}
.logo{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightblue;
    float: left;
}
.nav{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightgreen;
    float: right;
}
.header-image{
    width: 100%;
    border: 1px solid green;
    position: relative;
    z-index: 2;
    text-align: center;
}
.image{
    height: 100px;
    width: 60%;
    margin: 0 auto;
    margin-top: -20px;
    background: green;
    opacity: 0.6;
}
.header-image a{
    padding: 40px 0;
}
.menu-container{
    width: 100%;
    border: 1px red solid;
    height: 40px;
    margin-top: 50px;
}
只需将其添加到图像类:

margin: 0 auto;
margin-top: -20px;
试一试

只更改了css

body,html{margin: 10px;}
.header-container{
    width: 100%;
}
a{
    text-decoration:none;
    color:#000;
    padding: 10px 0px;
    display: block;
    text-align: center;
}
.nav-container{
    width: 100%;
    height: 50px;
    background: orange;
}
.logo{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightblue;
    float: left;
}
.nav{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightgreen;
    float: right;
}
.header-image{
    width: 100%;
    border: 1px solid green;
    position: relative;
    z-index: 2;
    text-align: center;
}
.image{
    height: 100px;
    width: 60%;
    margin: 0 auto;
    margin-top: -20px;
    background: green;
    opacity: 0.6;
}
.header-image a{
    padding: 40px 0;
}
.menu-container{
    width: 100%;
    border: 1px red solid;
    height: 40px;
    margin-top: 50px;
}
只需将其添加到图像类:

margin: 0 auto;
margin-top: -20px;
试一试

只更改了css

body,html{margin: 10px;}
.header-container{
    width: 100%;
}
a{
    text-decoration:none;
    color:#000;
    padding: 10px 0px;
    display: block;
    text-align: center;
}
.nav-container{
    width: 100%;
    height: 50px;
    background: orange;
}
.logo{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightblue;
    float: left;
}
.nav{
    width: 25%;
    height: 40px;
    margin: 5px;
    background-color: lightgreen;
    float: right;
}
.header-image{
    width: 100%;
    border: 1px solid green;
    position: relative;
    z-index: 2;
    text-align: center;
}
.image{
    height: 100px;
    width: 60%;
    margin: 0 auto;
    margin-top: -20px;
    background: green;
    opacity: 0.6;
}
.header-image a{
    padding: 40px 0;
}
.menu-container{
    width: 100%;
    border: 1px red solid;
    height: 40px;
    margin-top: 50px;
}
只需将其添加到图像类:

margin: 0 auto;
margin-top: -20px;

谢谢你的帮助。我还有一个小问题。看看这个。为什么我不能设置图像中心位置?为什么标题图像宽度大于父级的100%?这是因为您没有相对于父级的位置。添加相对于.header容器的位置。同样对于图像添加边距:0自动。这是jsfiddle:谢谢你的解释!现在我正在尝试为我的网站应用更改。最后一个问题,标题图像覆盖了紫色的购物车按钮。现在我无法点击它。有没有办法只通过图片而不是标题图片进行覆盖?谢谢你的帮助。我还有一个小问题。看看这个。为什么我不能设置图像中心位置?为什么标题图像宽度大于父级的100%?这是因为您没有相对于父级的位置。添加相对于.header容器的位置。同样对于图像添加边距:0自动。这是jsfiddle:谢谢你的解释!现在我正在尝试为我的网站应用更改。最后一个问题,标题图像覆盖了紫色的购物车按钮。现在我无法点击它。有没有办法只通过图片而不是标题图片进行覆盖?谢谢你的帮助。我还有一个小问题。看看这个。为什么我不能设置图像中心位置?为什么标题图像宽度大于父级的100%?这是因为您没有相对于父级的位置。添加相对于.header容器的位置。同样对于图像添加边距:0自动。这是jsfiddle:谢谢你的解释!现在我正在尝试为我的网站应用更改。最后一个问题,标题图像覆盖了紫色的购物车按钮。现在我无法点击它。有没有办法只通过图片而不是标题图片进行覆盖?谢谢你的帮助。我还有一个小问题。看看这个。为什么我不能设置图像中心位置?为什么标题图像宽度大于父级的100%?这是因为您没有相对于父级的位置。添加相对于.header容器的位置。同样对于图像添加边距:0自动。这是jsfiddle:谢谢你的解释!现在我正在尝试为我的网站应用更改。最后一个问题,标题图像覆盖了紫色的购物车按钮。现在我无法点击它。是否有一种方法仅通过图像覆盖,而不通过标题图像覆盖?