css嵌套divs垂直对齐

时间:2012-02-25 00:44:34

标签: css browser html margin vertical-alignment

我正在尝试找出如何在下面的示例中垂直间隔“按钮”-ID的最通用的方法。遗憾的是,这也必须在ie7中正确显示。

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
    <title>Box Model</title>
    <style type="text/css">
    body * {margin:0;padding:0;}

    .main {width:600px;height:200px;border:solid red 2px;}

    .myLblAndVal { float:left;width:350px; }

    #myLabels {
    float:left;
    width: 150px;
    text-align:right;
    }

    #myValues {
    float:right;
    width: 150px;
    display:inline;
    }

    #myButton {
    float:right;
    width: 200px;
    margin-top:10px; /* Do I have to use an absolute value? */
    }
    </style>
    </head>

    <body>
    <h1>Vertical Spacing</h1>

    <div class="main">
    <div class="myLblAndVal">
    <div id="myLabels">
      <p>111 Labels... Haec disserens qua de re agatur
      et in quo causa consistat non videt...</p>
    </div>
    <div id="myValues">
      <p>222 Values... causas naturales et antecedentes, 
      idciro etiam nostrarum voluntatum...</p>
    </div>
    </div>

    <div id="myButton">
      <p>333 Button... nam nihil esset in nostra 
      potestate si res ita se haberet...</p>
    </div>
    </div>
    </body> </html>

我必须使用绝对值吗?

感谢您的任何指示,

draptik

0 个答案:

没有答案