html部分
<div class="father">
     <div class="son"></div>
</div>
css部分
 .father {
    width: 300px;
    background: green;
  }

  .son {
    width: 200px;
    height: 200px;
    margin-right: auto;   //左对齐
    background: red;
  }

块级元素右对齐/左对齐

 .father {
    width: 300px;
    background: green;
  }

  .son {
    width: 200px;
    height: 200px;
    margin-left: auto;   ///右对齐
    background: red;
  }

块级元素右对齐/左对齐

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-11-21
  • 2021-04-06
  • 2022-02-06
  • 2022-02-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-05-23
  • 2022-12-23
  • 2022-01-15
  • 2021-11-30
相关资源
相似解决方案