Resize page elements based on window size

Problem: My client wants me to create a web page for my product so that there is no scrolling on the page, be it any browser or window size.

Doubt: Is this possible with CSS and Javascript?

Some early diagnoses: This may be a bit like this or this , but the difference is that I want to resize each element in a specific ratio, and not just adjust the height of the parent DIV.

So, the statement: I need to resize each element (images, divs, text ... all) based on the relationship between (current window size and help window size) . Perhaps Javascript may have a cure for this?

Question: How to do this?

+3
source share
1 answer

Simply install heightand widthfrom <html>and <body>to 100%, overflowin hiddenand use the interest for the left, top, widthand heightelements:

<!DOCTYPE html>
<html>
<head>
  <meta charset=UTF-8>
  <title>Proportional resizing</title>
  <style type="text/css">
    * {
      margin: 0;
      padding: 0;
    }

    html, body {
      height: 100%;
      overflow: hidden;
    }

    div {
      position: absolute;
      left: 30%;
      top: 20%;
      width: 40%;
      height: 30%;
      background-color: #ddd;
    }
  </style>
</head>
<body>
  <div>divthing</div>
</body>
</html>

, <body>.


. : . CSS 3 background-size (. ), . , (, : ).

+3

Source: https://habr.com/ru/post/1751294/


All Articles