我的div不想成为内包装

时间:2014-10-04 13:29:30

标签: html css

我的上一个div课程="图片"不想进入wrapperdiv并扩大其高度。它来自div之外,任何想法我怎么能解决它? 我不得不写一些文字,以便发布

 <div class="wrapper">                            
        <div class="logo"><img src="hello1.jpg"></div>

           <div class="menu"> 

            </div>
        </div>
        <div class="picture"><img src="hello.jpg"></div>

        </div>

我的css。

    div.wrapper {
        max-width: 1100px;
        padding: 0 25px;
        margin: 0 auto;
        background:#333;

    }

    div.logo
    {
        width:30%;

        margin-left: auto ;
        margin-right: auto ;
    }

    div.menu
    {
        margin-left: auto ;
        margin-right: auto ;
        width:325px;
        background:#FFF;
    }
div.picture
{
    margin-left: auto ;
    margin-right: auto ;

}

3 个答案:

答案 0 :(得分:3)

不确定您要完成哪种类型的用户界面,但您有一些格式错误的HTML。这是一个快速的解决方案。

<div class="wrapper">                            
     <div class="logo">logo</div>
     <div class="menu">menu</div>
     <div class="picture">picture</div>
</div>

http://jsfiddle.net/gwqrut4k/

答案 1 :(得分:0)

你有额外的&#34; / div&#34;在保持在外面的类之上

答案 2 :(得分:0)

请阅读此代码中的注释,您将能够理解该问题。感谢dmackerman,他给了你一个直接的答案。我只是想告诉你你似乎做错了什么。

<div class="wrapper">                            
        <div class="logo"><img src="hello1.jpg"></div> <!--You closed the logo -->

           <div class="menu"> 

 </div><!--You closed the  menu -->
        </div> <!--You closed the wrapper here is where your problem comes from ithink -->
        <div class="picture"><img src="hello.jpg"></div > <!--You closed the  picture -->

        </div> <!--This is where the wrapper would have been closed,  but you have closed it earlier -->