zz<h1>Нажмите 'Z'</h1>
<div class="block b1">
<div class="arc arc1"></div>
</div>
<div class="block b2" id="b2">
<div class="arc arc2"></div>
</div>
<div class="block b3">
<div class="arc arc3"></div>
</div>
html {
margin-top: 0px !important;
}
body{
padding:0px;
margin:0px;
background-color: #333;
}
.block{
background-color: white;
margin:80px;
}
.b1{
width: 500px;
height:400vh;
}
.arc1{
width:100px;
height:100px;
}
.b2{
width: 400px;
height:300px;
}
.arc2{
width:600px;
height:50px;
}
.b3{
width: 500px;
height:150px;
}
.arc3{
width:100px;
height:900px;
}
.arc{
background-color: #000;
}
var w1 = document.querySelector('.arc1').scrollWidth;
var h1 = document.querySelector('.arc1').scrollHeight;
var w2 = document.querySelector('.arc2').scrollWidth;
var h2 = document.querySelector('.arc2').scrollHeight;
var w3 = document.querySelector('.arc3').scrollWidth;
var h3 = document.querySelector('.arc3').scrollHeight;
var block_with1 = parseInt ($('.b1').css('width'));
var block_high1 = parseInt ($('.b1').css('height'));
var block_with2 = parseInt ($('.b2').css('width'));
var block_high2 = parseInt ($('.b2').css('height'));
var block_with3 = parseInt ($('.b3').css('width'));
var block_high3 = parseInt ($('.b3').css('height'));
var del_w1 = block_with1 / w1 ;
var del_h1 = block_high1 / h1 ;
var del_w2 = block_with2 / w2 ;
var del_h2 = block_high2 / h2 ;
var del_w3 = block_with3 / w3 ;
var del_h3 = block_high3 / h3 ;
var min1 = Math.min(del_w1, del_h1)
var min2 = Math.min(del_w2, del_h2)
var min3 = Math.min(del_w3, del_h3)
//Горячие клавиши
document.addEventListener('keypress', function(e) {
if( e.key.toLowerCase() == 'z' ){
document.querySelector(".arc1").style.width = (w1 * min1)+"px";
document.querySelector(".arc1").style.height = (h1 * min1)+"px";
document.querySelector(".arc2").style.width = (w2 * min2)+"px";
document.querySelector(".arc2").style.height = (h2 * min2)+"px";
document.querySelector(".arc3").style.width = (w3 * min3)+"px";
document.querySelector(".arc3").style.height = (h3 * min3)+"px";
}
});
This Pen doesn't use any external CSS resources.