Answer the question
In order to leave comments, you need to log in
How to correctly execute a script?
Hello!
I made a test site - 4.fishouk.z8.ru
At the bottom of the site there is a block of a button and a large picture background. In order for the picture to stretch normally to the entire width of the block, I wrote a jQuery script
$(document).ready(function(){
var currentHeihgt = $(document).width() * 0.625;
$("#buttonSection").css("height", currentHeihgt);
});
$(window).load(function(){
var currentHeihgt = $(document).width() * 0.625;
$("#buttonSection").css("height", currentHeihgt);
});
$(window).resize(function () {
var currentHeihgt = $(document).width() * 0.625;
$("#buttonSection").css("height", currentHeihgt);
});
Answer the question
In order to leave comments, you need to log in
If you don't want css, do this:
$(function(){
var currentHeihgt = $(document).width() * 0.625;
$("#buttonSection").css("height", currentHeihgt);
$(window).resize(function () {
var currentHeihgt = $(document).width() * 0.625;
$("#buttonSection").css("height", currentHeihgt);
});
});
Anyway, the script does not work correctly for you, because the picture is 1600, and you have 1100 added, well, in this case it is better to abandon JS
.buttonSection
{
background-size: cover;
height: 100%;
max-height: 1000px;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question