html - 并排对齐两个 div,覆盖整个页面宽度

标签 html css

我有这样的东西:

<div class="container">
    <div class="left">
        (an image)
    </div>
    <div class="right">
        (some divs and other text)
    </div>
</div>

我想并排对齐 2 个 div

.container {
    width: 100%;
}
.left, .right {
    float: left;
    width: 50%;
}

我需要做什么,因为这不起作用

最佳答案

您的代码没有问题... Div 并排对齐...

.container {
  width: 100%;
}

.left,
.right {
  float: left;
  width: 50%;
  
  border: 1px solid red;
  box-sizing: border-box;
}
<div class="container">
  <div class="left">
    (an image)
  </div>
  <div class="right">
    (some divs and other text)
  </div>
</div>

关于html - 并排对齐两个 div,覆盖整个页面宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43426117/

相关文章:

css - 带有弹出界面的 ionic 选择样式

javascript - 为什么 jQuery 使用原始 DOM 元素类,即使我用 jQuery 更改了它们?

javascript - gojs 中悬停按钮的自定义样式

html - 在 CSS 中为 ID 添加类

javascript - 另存为与 CSS 混合的图像 Canvas

html - Chrome 在网页末尾渲染额外的空白

html - 如何向背景图像添加超链接?

html - 将 css td/th 应用于类 "foo"的所有表

javascript - 半响应图像取决于宽度

javascript - slider - 在 HTML 视频中添加标题