html - 当浏览器变小时,如何将右栏 float 到左栏的中间

标签 html css

当浏览器变小时,如何将右列 float 到左列中间?

我想将它 float 在第一 block 和第二 block 之间。

CSS:

#leftcol{
    float:left;
    background:#039;
    width:300px

}
#rightcol{
    float:left;
    background:#3C0;
    width: 70%
}

#first{
    background:#F00;
    width:100%
}
#second{
    background:#666;
    width:100%
}

HTML:

<div>
  <div id=leftcol>leftcol
    <div id=first>first block</div>
    <div id=second>second block</div>
  </div>
  <div id=rightcol>rightcol</div>
</div>

最佳答案

更改 HTML:

<div id=first>first block</div>
<div id=rightcol>rightcol</div>
<div id=second>second block</div>

使用这个 CSS:

#rightcol{
  float:left;
  background:#3C0;
  width: 70%;
}
#first{
  float:left;
  background:#F00;
  width: 300px;
  clear: both;
}
#second{
  float:left;
  background:#666;
  width:300px;
  clear: both;
}

jsFiddle

关于html - 当浏览器变小时,如何将右栏 float 到左栏的中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16158316/

相关文章:

javascript - Jquery - 使用 HTML :selected to fetch an array with the same name

html - 将 Paypal 下拉列表更改为可点击的图像

html - chrome 上的隐形边距底部

CSS @media img [data] 不起作用?

javascript - 如何在 Vuetify(版本 >= 2.0)中单击时突出显示 v-data-table 中的行?

Javascript 显示/隐藏播放/暂停按钮

html - 当我将标题包裹在链接中时是否可以访问?

html - 边界像素的差异我不知道它来自哪里

javascript - 获取 HTML 元素大小

php - 删除结帐顶部链接 magento