Two divs alongside each other: first sticked and the second centered

前端 未结 1 1225
無奈伤痛
無奈伤痛 2021-01-26 05:41

I want to place two divs alongside each other. Second one to be centered and the first one to be on the left from second and to be sticked / fixed. Because of the last condition

相关标签:
1条回答
  • 2021-01-26 06:07

    Something like this:

    .container {
      display: flex;
      height:100%;
    }
    
    .left {
      margin-left: auto;
      width: 0;
      display: flex;
      justify-content: flex-end;
    }
    
    .centered {
      margin-right:auto;
      padding:5px;
      background:green;
      height:100%;
    }
    
    .left span {
      position:fixed;
      white-space: nowrap;
      padding:5px;
      background:red;
    }
    
    body {
     height:200vh;
    }
    <div class='container'>
      <div class='left'><span> some content</span></div>
      <div class='centered'>centered</div>
    </div>

    0 讨论(0)
提交回复
热议问题