html - 如何通过 css 调整特定框的大小

标签 html css

我想调整到右边的框,而左边的框值 (400px) 将被修复我如何通过 css 做到这一点?当我调整浏览器窗口的大小时,右边的框掉下来是不对的。这是 css 和 html。

#w {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  border: solid 1px #eee;
  box-sizing: border-box;
}
#left {
  max-width: 400px;
  width: 100%;
  border: solid 1px #000;
  height: 100px;
  float: left;
  box-sizing: border-box;
}
#right {
  max-width: 598px;
  width: 100%;
  border: solid 1px #000;
  height: 100px;
  float: left;
  box-sizing: border-box;
}
.clear {
  clear: both
}
<div id="w">
  <div id="left"></div>
  <div id="right"></div>
  <div class="clear"></div>
</div>

最佳答案

尝试

.div1 {
    width: 300px;
    height: 100px;
    border: 1px solid blue;
}

.div2 {
    width: 300px;
    height: 100px;
    padding: 50px;
    border: 1px solid red;
}

.div3 {
    width: 300px;
    height: 100px;
    border: 1px solid blue;
    box-sizing: border-box;
}

.div4 {
    width: 300px;
    height: 100px;
    padding: 50px;
    border: 1px solid red;
    box-sizing: border-box;
}
<h2>Without box-sizing</h2>
<div class="div1">This div is smaller (width is 300px and height is 100px).</div>
<br>
<div class="div2">This div is bigger (width is also 300px and height is 100px).</div>

<h2>With box-sizing</h2>
<div class="div3">Both divs are the same size now!</div>
<br>
<div class="div4">Hooray!</div>

关于html - 如何通过 css 调整特定框的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40521738/

相关文章:

javascript - CSS 样式表在 FireFox 中不起作用

javascript - 如何屏蔽特殊字符?

html -::selection 伪选择器忽略::before 伪元素

html - 如何将封面 div 放置到响应式 flex 容器中的对象适合图像上?

android - CSS 媒体查询不适用于 Android 4.1.2 Jellybean

google-chrome - CSS3 转换、分层和诊断

CSS 条件在 iPhone 6 中不起作用

javascript - 在 AngularJS 和 ui-router 中遇到嵌套状态的问题

javascript - 未经检查的 radio 不会发布其值

javascript - 使用 JS 在文本中查找并突出显示单词