Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class="page-container">
   <div class="page">
     Content
   </div>
    <div class="page">
     Content
   </div>
  </div>
</body>
</html>
 
.page-container {
    height: 7cm;
    width: 6cm;
    border: 1px solid black;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    background: orange;
    display: flex;
    flex-direction: column;
    resize: both;
    align-items: center;
    justify-content: flex-start;
    align-content: flex-start;
  }
.page {
    min-height: 29.7cm !important;
    max-height: 29.7cm !important;
    height: 29.7cm !important;
    width: 21cm !important;
    background: white;
    padding: 21mm;
    border: 1px solid gray;
    /* position: relative; */
    /* flex: 1 1 auto; */
  }
 
function resize() {
var firstPage = document.getElementsByClassName("page")[0];
var scaleX = (firstPage.parentElement.clientWidth - 30) / firstPage.clientWidth;
if (scaleX < 1) {
  [...document.getElementsByClassName("page")].forEach(page => {
    page.setAttribute("style", `transform:scale(${scaleX});`);  
  })
}
};
resize(); 
var ro = new ResizeObserver(target => {
  resize();
});
ro.observe(document
   .getElementsByClassName("page-container")[0]
);
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers