Search code examples
htmlcssheightwidth

How can i change width and height of element by changing width of browser windows?


I want width and height of my element change at the same time by changing the width of browser windows. how can i do it? and if height and width at first didn't have same size how they to be same in end?


Solution

  • If You want to change the width and height of an element based on your browser size you will have to give the width and height of that element in terms of percentage.

    div {
         width: 100%;
         height:100%;
         }
    

    In this case, the width and height of an element will auto-adjust based on the browser dimensions.