DIV里面另一个DIV里面另一个DIV用CSS [英] DIVs inside another DIV inside another DIV with CSS

查看:166
本文介绍了DIV里面另一个DIV里面另一个DIV用CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想达成的目标:

这是我写的HTML代码:

This is the HTML code I wrote:

<div id="wrapper"> <!--This is the Div 1 in the picture-->
    <div id="topBar"> <!--This is the Div 2 in the picture-->
        <div id="logo"></div> <!--This is the Div 4 in the picture-->
        <div id="menu"></div> <!--This is the Div 5 in the picture-->
        <div id="login"><!--This is the Div 6 in the picture-->
            <div class="loginElement"><input type="text" id="txtUsername" class="loginElementBox" size="29"  value="User name" onClick="usernameFocus()" onBlur="usernameBlur()" /></div>               
            <div class="loginElement">
                <input type="text" name="txtFakePassword" id="txtFakePassword" class="loginElementBox" value="Password" onfocus="passwordFocus()" /><input style="display:none;" type="password" id="txtPassword" class="loginElementBoxFocus" onBlur="passwordBlur()" />
            </div>

            <input type="button" id="btnLogin" value="" onclick="login()"><br />

            <span id="lblError"></span>
        </div><!--Closing "login"-->
    </div><!--Closing "topBar"-->

    <div id="central"> <!--This is the Div 3 in the picture-->
        <div id="top3"> <!--This is the Div 7 in the picture-->

        </div>
    </div><!--Closing "central"-->
</div><!--Closing "wrapper"-->

这是CSS:

#wrapper
{
width:800px;
background-color:#f2f2e8;
position:relative;
left:50%;
margin-left:-400px;
border-radius: 10px;
-moz-border-radius: 10px;
padding:5px;
}

#topBar
{
width:780px;
border: 1px solid;
border-color: #dbd9ca;
border-radius: 10px;
-moz-border-radius: 10px;
margin:5px;
padding:5px;
}

#logo
{
width:153px;
height:66px;
background-image:url(../images_ui/logo2.png);
background-repeat:no-repeat;
background-position:left center;
margin:5px;
padding:5px;
float:left;
}

#menu
{
float:left;
width:400px;
position:relative;
}

#login
{
float:right;
width:80px;
}

#central
{
width:780px;
border: 1px solid;
border-color: #dbd9ca;
border-radius: 10px;
-moz-border-radius: 10px;
margin:5px;
margin-top:20px;
padding:5px;
}

Inside Div 6我还有几个Div
出来乱。 Div 2和Div 3在Div 1内看起来OK,Div 7在Div 3内看起来不错,但是一旦我添加Div 3,4,5 ...我尝试了几个东西,浮动,位置等 - 没有什么工作,我可以' t安排它,因为我想要它。任何想法如何使它工作?

Inside Div 6 I have a few more Divs It all just comes out scrambled. Div 2 and Div 3 look OK inside Div 1, and Div 7 looks nice inside Div 3, but once I add Divs 3, 4, 5... I tried several things, with float, position etc - nothing worked, I can't arrange it as I want it. Any ideas how to make it work?

推荐答案

#Div1
{
width:800px;
margin:0 auto;
overflow:hidden;
float:left;
}

#Div2
{
width:100%;
float:left;
}

#Div3
{
width:100%;
clear:both;
}

#Div4, #Div6
{
float:left;
width:30%;
}

#Div5
{
float:left;
width:40%;
}

#Div7
{
width:70%;
margin:50px auto;
}

如果我没有忘记应该围绕它的事情

If I haven't forgotten something that should be round about it

这篇关于DIV里面另一个DIV里面另一个DIV用CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆