html - Javascript and W3CSS strange image behaviour -


using w3schools static slideshow css (and w3css): https://www.w3schools.com/w3css/w3css_slideshow.asp

however, images different heights , widths, want set them same height based on size of viewport, have modified javascript slideshow (see below, 566 , 1280 dimensions of shortest image), however, when using javascript slideshow comes out 0 height, yet when reporting "height" variable comes out @ correct (non-zero) value.

<script> var slideindex = 1;  showdivs(slideindex);  function plusdivs(n) {     showdivs(slideindex += n); }  function showdivs(n) {     var i;     var x = document.getelementsbyclassname("gallery");     if (n > x.length) {slideindex = 1}      if (n < 1) {slideindex = x.length} ;     (i = 0; < x.length; i++) {         x[i].style.display = "none";      }     x[slideindex-1].style.display = "block";      var height = (document.documentelement.clientwidth*566/1280);     x[slideindex-1].height = height+"px"; } </script> 

your last line incorrect. should be:

x[slideindex-1].style.height = height+"px"; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -