Țaman ŞheƦzad Țaman ŞheƦzad - 2 months ago 6
CSS Question

jQuery get height of viewport size but -(n)px

Sorry if the subject is confusing couldn't know how to explain better,
so i use jQuery to set a div height to match viewport size

var slidevh = function() {
var bheight = $(window).height();
$(".container").css('height', bheight);

Now this works fine, But I want the height to become - 100 pixels of the viewport size,
for example if the height was 500px I want the size to become 400px :)

is there any better way to do this? maybe pure css?


you can use css calc mixin

.container {
   height: calc(100vh - 100px);

in javascript jquery

var slidevh = function() {
    var bheight = $(window).height();
    $(".container").css('height', bheight - 100);