css - 列下推 css 问题

标签 css

我在网上搜索过,但找不到答案。希望有人帮助我 出。

在我的页面中,右栏被向下推到左栏下方,因为 宽度问题。有什么办法我不需要改变所有的宽度 元素?我的意思是让右栏与类所在的 div 重叠 包装器?

有我的html页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>My first styled page</title>
<style type="text/css">

body {
    color: purple;
}

div.wrapper {
    width: 80%;   
    border-style:solid; 
    border-color:black;
}

 div.one {
    width: 300px;
    float: left;
    height: 300px; 
    border-style:solid;
    border-color: #0000ff;  
}

div.two {
    width: 1024px;
    border-style:solid;
    border-color:yellow ;
}

</style>
</head>
<body>
    <div class="wrapper">
        <div class="one">The left column</div>
        <div class="two">The right column</div>
    </div>
?
</body>

这是我的页面的屏幕截图: enter image description here

最佳答案

解决方案:

<!DOCTYPE HTML>
<html>
    <head>
        <title>My first styled page</title>
        <style type="text/css">
            body {
                color:purple;
            }
            div.wrapper {
                width:80%;   
                float:left;
                border-style:solid; 
                border-color:black;
            }
            div.one {
                width:45%;
                float:left;
                height:300px; 
                border:1px solid blue; 
            }
            div.two {
                width:45%;
                float:right;
                border:1px solid yellow;
            }
        </style>
    </head>
    <body>
        <div class="wrapper">
            <div class="one">The left column</div>
            <div class="two">The right column</div>
        </div>
    </body>
</html>

结果:
enter image description here

关于css - 列下推 css 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16780524/

相关文章:

html - .row 内的水平居中列

css - 为什么我访问过的链接没有背景颜色?

javascript - Twitter Bootstrap 示例在 IE8 中不工作

需要空间才能执行正确操作的 CSS 函数和命令

css - 改进 CSS 动画

html - 填充集时,相对父级内部的绝对定位会溢出 div

css - 如何将减少的 reCaptcha 居中? HTML CSS

html - 去除边界 Angular 的斜 Angular 效果

javascript - 在 datalist 控件中调用 jquery 函数

html - 如何将两个 div 放在同一行上并让它们响应?