Я сделал уменьшение блока при уменьшении ширины экрана, но я ничего не могу сделать, чтобы уменьшить его с уменьшением высоты, как это можно сделать? ......... .................................................. .................................................. .................................................. .................................................
https://jsfiddle.net/kepamuk/wc91xo4b/
html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>
<div class="navbar"></div>
<div class="scaleable-wrapper" id="scaleable-wrapper">
<div class="very-specific-design" id="very-specific-design">
<h1>I am designed just so.</h1>
<p>My design is intentional. I want to be scaled in such a way that scales the design. No reflows or anything,
just straight up scaling. Kinda like SVG.</p>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/skull-and-crossbones.svg" alt=""/>
<p class="bigred"> ✖ ✖ ✖ </p>
</div>
</div>
<script>
$(document).ready(function () {
var $wrapper = $("#scaleable-wrapper");
var $el = $("#very-specific-design");
var elWidth = $el.outerWidth();
var elHeight = $el.outerHeight();
$(window).resize(function () {
size();
});
size();
function size() {
var scale;
console.log('$wrapper.width()', $wrapper.width())
console.log('elWidth', elWidth)
console.log('$wrapper.height()', $wrapper.height())
console.log('elHeight', elHeight)
scale = Math.min(
$wrapper.width() / elWidth,
$wrapper.height() / elHeight
);
$el.css({
transform: "translate(-50%, -50%) " + "scale(" + scale + ")"
});
}
});
</script>
</body>
</html>
css
body {
background: #ccc;
box-sizing: border-box;
padding: 40px 40px 40px 100px;
margin: 0;
}
.navbar{
background-color: grey;
width: 40px;
height: 100vh;
position: absolute;
left: 0;
top: 0;
}
.very-specific-design {
width: 877px;
height: 593px;
padding: 50px;
text-align: center;
background: white;
position: relative;
left: 50%;
top: 50%;
}
.scaleable-wrapper {
box-sizing: border-box;
padding: 20px;
background: #666;
height: 593px;
}
.ui-resizable-se {
width: 10px;
height: 10px;
background: orange;
position: absolute;
bottom: 0;
right: 0;
}
.bigred {
color: red;
font-size: 5rem;
}
Мое решение
Я добавил
height: calc(100vh - 80px);
в .scaleable-wrapper, но, возможно, есть лучший вариант