0

If I try to set the height of an element I can't get it working. I have tried doing it with css and jquery but both without result.

This is the css I tried:

#slider{
 width:100%;
 height:100%;
 background-image: url(/img/background.jpg);
 background-size: 100%;
}

and this the Jquery code

var screen_height = $(document).height();
$('#slider').css('Height', screen_height );

does somebody know how to fix this. This is not the first time I have this problem and normally I can fix it with Jquery but now even that doesn't work.

Vinc199789
  • 1,046
  • 1
  • 10
  • 31

4 Answers4

2

So if you are inserting another page into #page you need to add the height of the slider when the loading is complete.

$( "#page" ).load( "content.php", function() {
    $('#slider').height( $(window).height() );
});

Or like this

$( "#page" ).load( "content.php", function() {
    $('body').find('#slider').height( $(window).height() );
});
Bojan Petkovski
  • 6,835
  • 1
  • 25
  • 34
0

try this:-

var screen_height = $(document).height();
$('#slider').css('height', screen_height );

or

$('#slider').height(screen_height );
Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68
0

For height: 100%; to work in #slider, you must also have an explicit height set in its parent. Or, have relative height set in all ancestors all the way up to and including html or an ancestor with explicit height set.

TylerH
  • 20,799
  • 66
  • 75
  • 101
0

Use this DEMO

var screen_height = $(document).height();
$('#slider').css({height: screen_height});
Gildas.Tambo
  • 22,173
  • 7
  • 50
  • 78