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

前端 未结 1 1226
無奈伤痛
無奈伤痛 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;
    }
    some content
    centered

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