App下載
首頁(yè)htmlalignCSS Layout - 如何左右對(duì)齊

CSS Layout - 如何左右對(duì)齊

我們想知道如何左右對(duì)齊。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.parent {
  width: 100%;
  height: 50px;
  background: #888;
  position: relative
}

.left {
  float: left;
  height: 100%;
  width: 50px;
  background: green;
}

.right {
  background: red;
  position: absolute;
  bottom: 0;
  left: 50px;
  right: 0;
  top: 0
}
</style>
</head>
<body>
  <div class="parent">
    <div class="left"></div>
    <div class="right"></div>
  </div>
</body>
</html>