简体   繁体   English

如何使此横幅滑块适合浏览器高度?

[英]How to make this banner slider to fit the browser height?

I googled for 2 days trying to understand how the auto height fit works, I think I understand in how to make a background fits the browser, but with this banner slider, I don't have a clue. 我在Google上搜索了2天,试图了解自动高度调整的工作原理,我想我了解如何使背景适合浏览器,但是对于这个横幅滑块,我却一无所知。

Could someone please enlighten me on where should I look for/start? 有人可以启发我在哪里寻找/开始吗? Should it be a CSS or JS ? 应该是CSS还是JS

I'm very new to HTML5/CSS3 , Wordpress gave me a very easy environment to start a website, but I just barely know how to modify a website other than a plugin. 我对HTML5/CSS3还是很HTML5/CSS3Wordpress为我提供了一个非常轻松的环境来启动网站,但是除了插件之外,我几乎不知道如何修改网站。

It would be very cool if the slider section to fit like this one below 如果滑块部分像下面这样适合,那将非常酷 想要的结果

Thanks in advance! 提前致谢!

This should set the image/album you have on the homepage to be the height and width of the browser, tweak some of the CSS and it should line up with the Sidebar perfectly like you wanted. 这应该将主页上的图像/相册设置为浏览器的高度和宽度,并调整一些CSS,并且应该与侧边栏完美地对齐,如您所愿。

  img {
        max-width: 100%;
        height: auto;
        width: auto\9;
    }

If you are looking for the image that fits the browser height regardless of any display then you can use 'vh' unit from this css units page. 如果您正在寻找适合浏览器高度的图像,而不管显示内容如何,​​则可以从此CSS单位页面使用“ vh”单位。

vh means viewport height[viewport = the browser window size.], and 1vh = 1% of the height of viewport, so in your case you can use 100vh for image like this: vh表示视口高度[viewport =浏览器窗口大小。],并且1vh =视口高度的1%,因此在您的情况下,您可以对图像使用100vh,如下所示:

img{
  height: 100vh;
}

Check this jsfiddle for the same. 检查此jsfiddle是否相同。

Remember that you need high-resolution images and those images will not look good on mobile devices. 请记住,您需要高分辨率的图像,并且这些图像在移动设备上看起来不会很好。

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

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