左侧menu随右侧contet自适应

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<style>
p{
  margin: 0px;
}
.box{
  float: left;
  position: relative;
  width: 1000px;
  border: 1px solid red;
}
.box .left{
  background: red;
  position: absolute;
  height: 100%;
  width: 80px;
}
.box .right{
  margin-left: 80px;
  padding: 20px;
  background: beige;
}
.box .sp{
  position: relative;
  top: 50%;
  margin-top: -11px;
  display: block;
  text-align: center;
}


.box1{
  display: table;
  width: 1000px;
  border: 1px solid red;
}
.box1 .left{
  display: table-cell;
  background: red;
  width: 80px;
  vertical-align: middle;
  text-align: center;
}
.box1 .right{
  display: table-cell;
  padding: 20px;
  background: beige;
}

.box2{
  display: flex;
  width: 1000px;
  border: 1px solid red;
}
.box2 .left{
  width: 80px;
  background: red;
  text-align: center;
}
.box2 .right{
  flex: 1;
  background: beige;
  padding: 20px;
}
.box2 .sp{
  position: relative;
  top: 50%;
  margin-top: -11px;
}

</style>
</head>
<body>
<!--1、position:absolute;height:100%-->
<div class="box">
  <div class="left">
    <span class="sp">左侧</span>
  </div>
  <div class="right">
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
  </div>
</div>
<div style="clear: both;margin-bottom: 40px;"></div>
<!--2、display:teble-->
<div class="box1">
  <div class="left">
    <span class="sp">左侧</span>
  </div>
  <div class="right">
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
  </div>
</div>
<div style="clear: both;margin-bottom: 40px;"></div>
<!--3、display:flex-->
<div class="box2">
  <div class="left">
    <span class="sp">左侧</span>
  </div>
  <div class="right">
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
    <p>1111</p>
  </div>
</div>
</body>

 

猜你喜欢

转载自www.cnblogs.com/yuyedaocao/p/9493881.html