html - Div 无缘无故下降?

标签 html css

我有以下CSS

.container {margin-left:auto; margin-right:auto; width:1020px;}
.body {float:left; width:1020px;}
.leftcont {float:left; width:206px;}
.left {float:left; width:205px;border-right-width:thin;border-right-style:solid; padding-right:5px;}
 .right {float:left;width:813px; padding: 20px;}

html:

<div class="container">
<?php
include("navigation/footNav.php");
?>



<div class="body">
    <div class="leftcont">
        <?php
        if($session->logged_in){ 
            include("navigation/sideLogIn.php");
        }
        else
        {
            include("navigation/sideLogOut.php");
        }
        ?>
        <div class="left">
            <div class="bar">
                <h1 class="title">Page Menu</h1>
                <div class="arrow"></div>
                <a href="/settings.php" class="list">My Settings</a>
                <br />
                <div class="arrow"></div>
                <a href="/process.php" class="list">Logout</a>
                <br />
            </div>
        </div>

    </div>
    <div class="right">
        THis text
    </div>
</div>
<?php
include("navigation/footer.php");
?>

leftcont 和 right 应该并排排列。但由于某种原因,右边的 div 低于左边的?

有什么想法吗?

谢谢

最佳答案

您的 .body 宽度为 1020px,其中将包含 .leftcont206px.right 813px,但它不会padding: 20px 保持它,这使得宽度有效 843

您需要减少 .right 上的填充或宽度,或者扩展 .body 上的 with。

关于html - Div 无缘无故下降?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4581312/

相关文章:

html - <li>,元素符号列表当前未排列

html - bootstrap 颜色是如何工作的?

H1 中的 HTML H3 元素

javascript - 使网页的 CSS 和 JS 跨浏览器兼容的最佳实践是什么?

php,流量捕手

html - 无法使图像填满背景并在链接悬停时保持纵横比

javascript - 单击带有常规 javascript 的 div

html - 复选框出现 gary 并在 Galaxy Built in 浏览器和 Maxthon 中选中

javascript - &lt;script&gt; 标记在 HTML <pre> 标记中的无效位置

javascript - 如何使 1 个 css 值依赖于另一个?