Keeping parent div to width and height of wrapping children

前端 未结 3 769
粉色の甜心
粉色の甜心 2021-01-26 02:16

I am building a simple calendar. I am wanting the months to wrap responsively on screen, and the parent container to keep the width and height of its children. For example, if t

3条回答
  •  长发绾君心
    2021-01-26 02:42

    html,
    body {
      box-sizing: border-box;
      font: 400 16px/1.5'Palatino Linotype';
      height: 100vh;
      width: 100vw;
      overflow-x: auto;
      overflow-y: auto;
    }
    *,
    *:before,
    *:after {
      box-sizing: inherit;
      margin: 0;
      padding: 0;
      border: 0;
    }
    body {
      background-color: #222;
      color: #EFE;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }
    .shell {
      display: flex;
      position: relative;
      padding: 1.5em .75em;
      margin: 0 auto;
      height: 300%;
      width: 300%;
      width: -moz-max-content;
      width: -webkit-max-content;
      width: max-content;
    }
    .content {
      position: absolute;
      font-variant: small-caps;
      left: 0;
    }
    .cal {
      display: flex;
      flex-flow: row wrap;
      outline: 3px solid yellow;
      width: -moz-min-content;
      width: -webkit-min-content;
      width: min-content;
      max-width: 900px;
      flex: 3 0 90%;
    }
    .month {
      float: left;
      width: 250px;
      height: 170px;
      outline: 3px solid red;
      display: inline-block;
      flex: 1 1 50%;
    }
    
    
    
    
    
    
    
      
    Jan
    Feb
    Mar
    Apr
    May
    Jun
    Jul
    Aug
    Sep
    Oct
    Nov
    Dec

提交回复
热议问题