html - 边栏框一个下一个

标签 html css

简单却想不通。我可以制作 2 个边栏框,一个在顶部,一个在下方。这是演示 http://jsfiddle.net/logintomyk/fQPse/

<div id="sidebar">
     Text<br/>Sidebar
</div>
<div id="sidebar">
     Text<br/>Sidebar
</div>

那两个侧边栏 div。

最佳答案

用父元素包裹侧边栏,您也添加了 float:right CSS

#wrapper {
  width: 90%;
}
#header {
  width: 100%;
  height: 50px;
  background-color: lightblue;
}
#content {
  /* *** I want something that will change width to fill blank space when the user re-sizes the browser and the sidebar moves *** */
  margin-top: 4px;
  background-color: yellow;
}
#content >p {
  margin-right: 100px;
  margin-top: 0px;
}
.sidebarGroup {
  width: 100px;
  float: right;
}
.sidebar {
  width: 100px;
  margin-top: 4px;
  background-color: pink;
}
#footer {
  width: 100%;
  height: 40px;
  margin-top: 4px;
  background-color: red;
}
<div id="Wrapper">
  <div id="header">
    header
  </div>
  <div class="sidebarGroup">
    <div class="sidebar">
      Text
      <br/>Sidebar
    </div>
    <div class="sidebar">
      Text
      <br/>Sidebar
    </div>
  </div>


  <div id="content">
    <p>
      Stuff
      <br/>text
      <br/>Just to fill some space
    </p>
  </div>

  <div id="footer">
    footer
  </div>
</div>

关于html - 边栏框一个下一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41045981/

相关文章:

html - 文本在跨度内对齐

html - 替换元素的 CSS 固有大小

html - 添加元素时时间轴 slider 被压缩

JavaScript 滚动检测和滚动速度

javascript - 使用 method=get 在表单提交上使用页面 anchor

php - 如何在 <td> 中的单行中获取数据,数据库中具有相同 ID 的多个条目

javascript - Angular/HTML - 将显示完整的 JSON 但不能仅显示单个属性

css - react : SVG hover color doesn't disappear when setting active unless mouse touches screen

css - 用于生产的 rake Assets 预编译语法错误

html - 关于剩余的垂直空间垂直居中一条线