简体   繁体   English

无论窗口大小如何,如何获取徽标,幻灯片和图像以覆盖整个屏幕

[英]How do I get my logo, slideshow and image to cover my entire screen no matter the window size

I would like to get all three of these divs (logo, slideshow, and subslider) to fit the entire screen window no matter the size. 我想让所有这三个div(徽标,幻灯片和subslider)都适合整个屏幕窗口,而不管大小如何。 I basically want to mimic the background:cover action in CSS but with all three of these elements. 我基本上想模仿CSS中的background:cover动作,但要包含所有这三个要素。 From my research I need to do something in javascript but I just can't seem to get it to work no matter what I try. 从我的研究中,我需要使用javascript做一些事情,但是无论我如何尝试,我似乎都无法使其正常工作。 I would also like to note that I am using drupal if that changes anything... Despite reading a lot on the subject, I'm way out of my comfort zone when it comes to trying to understand window resizing issues, any help, advice, and code snippets would be a godsend please! 我还想指出的是,如果这发生了任何变化,我将使用drupal ...尽管阅读了很多有关该主题的内容,但是在尝试了解窗口大小调整问题,任何帮助和建议时,我还是走出了我的舒适区,代码片段将是天赐之物!

所有图像和幻灯片均居中并水平堆叠:)

<div class="logo">
<img src="sites/all/themes/cpd pro/images/cpd.jpg" alt="Center for Passion Development">
</div>
<!-- *************SLIDESHOW***************-- -->
<div id="slider">
<img src="sites/all/themes/cpd pro/images/slide1.jpg"/>
<img src="sites/all/themes/cpd pro/images/slide2.jpg"/>
<img src="sites/all/themes/cpd pro/images/slide3.jpg"/>
<img src="sites/all/themes/cpd pro/images/slide4.jpg"/>
<img src="sites/all/themes/cpd pro/images/slide5.jpg"/>
</div>  
<!-- *************BELOW SLIDESHOW IMAGE***************-- -->
<div class="subslider">
<h5><img src="sites/all/themes/cpd pro/images/nav-wrap.png" alt="navigation">  </h5>
</div>

Use vh unit in CSS . 在CSS中使用vh单位 100vh is exactly 100% of your viewport's height, so you can make your 3 divs heights sum to 100vh. 100vh恰好是视口高度的100%,因此您可以使3 div的高度总和为100vh。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM