Html 我的DIV位于前一个DIV的顶部

Html 我的DIV位于前一个DIV的顶部,html,css,Html,Css,我刚刚开始整理我的网站。我有一个滚动的横幅DIV,现在我想在“largemenubutton”DIV下面添加一个图像,但当我把它放在横幅上方时?我已经把CSS中的明确:左,但这不起作用 html <body> <div class="mainhome"> <div class="header"> <div class="menubutton-leftside" style=

我刚刚开始整理我的网站。我有一个滚动的横幅DIV,现在我想在“largemenubutton”DIV下面添加一个图像,但当我把它放在横幅上方时?我已经把CSS中的明确:左,但这不起作用

html

       <body>
        <div class="mainhome">
            <div class="header">
              <div class="menubutton-leftside" style="margin-right:23px"><h2>home</h2></div>
              <div class="menubutton-leftside" style="margin-right:20px"><h2>about</h2></div>
              <div class="menubutton-leftside" style="margin-right:30px"><h2>portfolio</h2></div>
              <div class="menubutton-leftside" style="margin-right:27px"><h2>contact</h2></div>
                <div class="logo"><img src="images/es-logo.png" width="170" height="170" /></div> 
              <div class="menubutton-rightside" style="margin-left:17px"><h2>print</h2></div>
              <div class="menubutton-rightside" style="margin-left:25px"><h2>digital</h2></div>
              <div class="menubutton-rightside" style="margin-left:38px"><h2>illustration</h2></div>
              <div class="menubutton-rightside" style="margin-left:20px"><h2>brand</h2></div>
          </div>
                <div class="mainimage">
                <div id="slider_container">
          <div id="slides">
                        <img src="images/slider/emmasteed.png" alt="Emma Steed Graphic Art and Web Design" />
                        <img src="images/slider/graphicdesign-desk.png" alt="Emma Steed Graphic Art and Web Design" />
          </div>
        </div>
    <div class="bluebar"></div></div>
                <div class="largemenubutton"><img src="images/portfolio.png" /></div>
        </div>
我在这儿闲逛
问题是在
蓝巴之后有一个额外的
,因此
largemenubton
不在同一个容器中
main image
,该容器是绝对定位的(因此如果
main image
根本不在那里,
largemenubton
就在它应该坐的地方)


而且你不能像浮动那样“清除”绝对位置。
因此,解决方法是将有问题的
向下移动两行,从而将
大菜单按钮
放在
主菜单中



请参阅。

您好,如果您添加了一个使用JSFIDLE的示例,我们可以使用该示例查看并尝试解决您的问题,这将有所帮助!
@charset "UTF-8";
/* CSS Document */

body {
    background-image:url(images/header-background.png);
    background-repeat:repeat-x;
    margin:0;
}

.mainhome {
    width: 855px;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
}

.header {
    height: 236px;
    background-image:url(images/header-background.png);
    background-repeat:repeat-x;
    clear:left;
}

.mainimage {
    width: 855px;
    height: 423px;
    background-color:#0C9;
    position:absolute;
    top:220px;
    clear:left;
    float:left;
    z-index:-1;
}

#slider_container {
        width:855px;
        height:423px;
        overflow:hidden;
}

.bluebar {
    width: 855px;
    height: 16px;
    background-color:#334d5c;
    clear:left;
    float:left;
}

.menubutton-leftside {
    width:60px;
    height:20px;
    float:left;
    margin-top:95px;
}

.menubutton-rightside {
    width:60px;
    height:20px;
    float:left;
    margin-top:95px;
    text-align:right;
}

h2 {
    font-family:Tahoma, Geneva, sans-serif;
    font-size:12px;
    font-weight:normal;
    color:#666;
    display:inline;
}

.logo {
    width:170px;
    height:170px;
    float:left;
    margin-top:30px;
}

.largemenubutton {
    width:261px;
    height:259px;
    float:left;
    clear:left;
}