How to auto adjust the div size for all mobile / tablet display formats?

后端 未结 9 997
一个人的身影
一个人的身影 2020-12-07 11:36

I have designed a page where four div tags are there in the page. If I test the page in mobile phone (5 inch) it fits the page perfectly, If I test the same pag

9条回答
  •  悲&欢浪女
    2020-12-07 12:35

    Fiddle

    You want to set height which may set for all devices?

    Decide upon the design of the site i.e Height on various devices.

    Ex:

    • Height-100px for bubbles on device with -min-width: 700px.
    • Height-50px for bubbles on device with < 700px;

    Have your css which has height 50px;

    and add this media query

      @media only screen and (min-width: 700px) {
        /* Styles */
        .bubble {
            height: 100px;
            margin: 20px;
        }
        .bubble:after {
            bottom: -50px;
            border-width: 50px 50px 0;
        }
        .bubble:before {
            top: 100px;
            border-width: 52px 52px 0;
        }
        .bubble1 {
            height: 100px;
            margin: 20px;
        }
        .bubble1:after {
            bottom: -50px;
            border-width: 50px 50px 0;
        }
        .bubble1:before {
            top: 100px;
            border-width: 52px 52px 0;
        }
        .bubble2 {
            height: 100px;
            margin: 20px;
        }
        .bubble2:after {
            bottom: -50px;
            border-width: 50px 50px 0;
        }
        .bubble2:before {
            top: 100px;
            border-width: 52px 52px 0;
        }
    }
    

    This will make your bubbles have Height of 100px on devices greater than 700px and a margin of 20px;

提交回复
热议问题