CSS scale height to match width - possibly with a formfactor

前端 未结 10 1744
天涯浪人
天涯浪人 2020-12-04 11:28

I have implemented a GoogleMapsV3 map in a twitterBootstrap basic responsive design site.

But my question is quite simple: i have:

10条回答
  •  一生所求
    2020-12-04 11:49

    You can set its before and after to force a constant width-to-height ratio

    HTML:

    CSS:

    .squared {
      background: #333;
      width: 300px; 
    }
    .squared::before {
      content: '';
      padding-top: 100%;
      float: left;
    }
    .squared::after {
      content: '';
      display: block;
      clear: both;
    }
    

提交回复
热议问题