LADYX,
ещё вариант ...
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style>
#parent {
width: 300px;
height: 300px;
padding: 10px;
border: 5px solid red;
position: relative;
}
#children {
position: absolute;
width: 300px;
height: 300px;
background: green;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
</style>
<script>
function parentH() {
let height = document.querySelector('#parent_range_H').valueAsNumber;
let width = document.querySelector('#parent_range_W').valueAsNumber;
document.querySelector('#parent').style.height = height + 'px';
let style = document.querySelector('#children').style;
height <= width && (style.height = style.width = height + 'px');
}
function parentW() {
let height = document.querySelector('#parent_range_H').valueAsNumber;
let width = document.querySelector('#parent_range_W').valueAsNumber;
document.querySelector('#parent').style.width = width + 'px';
let style = document.querySelector('#children').style;
height >= width && (style.height = style.width = width + 'px');
}
</script>
</head>
<body>
<p>height: <input id="parent_range_H" type="range" min="10" max="300" value="300" step="1" name="parent_h" oninput="parentH()">
width: <input id="parent_range_W" type="range" min="10" max="300" value="300" step="1" name="parent_w" oninput="parentW()"></p>
<div id="parent">
<div id="children"></div>
</div>
</body>
</html>