html - 如何在屏幕底部正确放置一个 div?

标签 html css

如果右侧单元格中的内容增长,我想在页面底部的左侧单元格中放置一个 div 。我该怎么做?

div 位于 #cell-right 和菜单项 1 之间。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>sd</title>
    <style type="text/css">
      html, body {
      width:100%;
      background:#6f711a;
      border:0px solid red;
      margin:0;
      padding:0;
      font-family:Arial;
      }
      #wrapper {
      width:1220px;
      padding:0;
      margin:10px auto;
      background:#ccc;
      border:3px solid white;
      }
      #content {
      background:#444;
      float:left;
      width:100%;
      min-height:620px;
      padding:0;
      margin:0;
      border:0px solid;
      }
      #cell-left {
      background-color:#444;
      float:left;
      width:195px;
      height:100%;
      padding:0;
      margin:0;
      border:0px solid;
      }
      #cell-right {
      float:right;
      width:1025px;
      height:100%;
      padding:0;
      margin:0;
      border:0px solid;
      }
      #footer {
      background-color:#000;
      color:#fff;
      clear:both;
      height:25px;
      padding:4px;
      margin:0;
      text-align:center;
      border:0px solid;
      }
      #cell-right #content-right{
      padding:10px 10px 0 10px;
      }
      #cell-left #content-left{
      padding:0;
      margin:0;
      }
      #content-left {
      position:relative;
      height:100%
      }
      #content-right {
      background:#f1f1f1;
      }
      #content-left ul li a {
      border-bottom: 1px solid #fff;
      color: white;
      display: block;
      overflow: auto;
      padding: 10px;
      text-decoration: none;
      }
      ul {
      border: 0 none;
      font: bold 13px Verdana;
      list-style-type: none;
      margin: 0;
      padding: 0;
      width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="wrapper">
      <div id="content">
        <div id="cell-left">
          <div id="content-left">
            <ul>
              <li><a href="#">menu item 1</a></li>
            </ul>
            <div style="vertical-align:bottom;height:100%;">vertically align on bottom</div> This is the div that needs to rest on the bottom
          </div>
        </div>
        <div id="cell-right">
          <div id="content-right">
            Lorem ipsum dolor sit amet consectetuer eget at enim ac eget. 
            Tellus nibh non ut congue montes parturient natoque odio at ipsum. 
            Id aliquet ante arcu feugiat Lorem dis ut libero laoreet dui. 
            Id tincidunt elit Nulla ut elit Nulla dui ullamcorper magnis ipsum. 
            Turpis Donec risus Proin tristique egestas hendrerit Vestibulum sed ut orci. 
            Pede adipiscing a et magna ultrices ipsum Aenean a ut laoreet. 
            Sed vitae vitae eu nibh pellentesque quis orci vitae at Aenean.
            .. lots more of text here ..
          </div>
        </div>
      </div>
      <div id="footer">sdsd</div>
    </div>
  </body>
</html>

最佳答案

使用与现在相同的 CSS。像这样改变 body :

<body>
<div id="wrapper">
  <div id="content">
    <div id="cell-left">
      <div id="content-left">
        <ul>
          <li><a href="#">menu item 1</a></li>
        </ul>
      </div>
    </div>
    <div id="cell-right">
      <div id="content-right" style="position:relative">
        Lorem ipsum dolor ... bla bla bla
        <div style="position:absolute; left:-185px; bottom:10px; width:180px">This is the div that needs to rest on the bottom vertically align on bottom</div> 
      </div>
    </div>
  </div>
  <div id="footer">sdsd</div>
</div>
</body>

实际上我只改变了这些行:

  <div id="content-right" style="position:relative">
    Lorem ipsum dolor ... bla bla bla
    <div style="position:absolute; left:-185px; bottom:10px; width:180px">This is the div that needs to rest on the bottom vertically align on bottom</div> 
  </div>

关于html - 如何在屏幕底部正确放置一个 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6125115/

相关文章:

html - ul 标签设置响应不工作

html - 我的内容 <p> 在移动设备上缩小

html - 如何在任何图标和文本上方显示我的上层菜单?

css - 在 Sass 文件中写入 CSS 在 Angular 7 中抛出错误

html - 将 css 下拉菜单对齐到中心

javascript - 从数独表 HTML 表生成数字数组

html - 我无法在页面中水平居中内容

javascript - Selenium WebDriver : clicking a visible button inside a row of a table

html - CSS - margin top of 50% 超过 50%

html - 如何在焦点和打字时将占位符移至顶部