Set auto height and width in CSS/HTML for different screen sizes

后端 未结 3 1786
抹茶落季
抹茶落季 2021-02-04 21:18

I have 2 issues with this layout :

  1. .feature_content (grey background) adapt it\'s height and width to different screen sizes
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-04 21:40

    This is what do you want? DEMO. Try to shrink the browser's window and you'll see that the elements will be ordered.

    What I used? Flexible Box Model or Flexbox.

    Just add the follow CSS classes to your container element (in this case div#container):

    flex-init-setup and flex-ppal-setup.

    Where:

    1. flex-init-setup means flexbox init setup; and
    2. flex-ppal-setup means flexbox principal setup

    Here are the CSS rules:

     .flex-init-setup {
         display: -webkit-box;
         display: -moz-box;
         display: -webkit-flex;
         display: -ms-flexbox;
         display: flex;
     }
     .flex-ppal-setup {
         -webkit-flex-flow: column wrap;
         -moz-flex-flow: column wrap;
         flex-flow: column wrap;
         -webkit-justify-content: center;
         -moz-justify-content: center;
         justify-content: center;
     }
    

    Be good, Leonardo

提交回复
热议问题