When I wrote the demo last time, I found that position was a little bit different from what I thought it was, and if I didn’t set the value of position top and bottom, the top and bottom would still be in the normal layout

HTML

<div class="container">
  <div class="bro"></div>
  <div class="btn"></div>
</div>
Copy the code

CSS

.container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 100;
        overflow: hidden;
        background: #f2f3f4;
      }
      .bro{
        position: relative;
        width: 100%;
        height: 75%;
        box-sizing: border-box;
        border: 1px solid black;
      }
      .btn {
        position: absolute;
        left: 0;
        right: 0;
        margin: auto;
        width: 120px;
        height: 40px;
        background: red;
        color: #fff;
        border-radius: 20px;
      }

Copy the code

The display result is shown in the figure.

Found that want to makebtnCenter, must be set simultaneouslyleft right margin