简体   繁体   English

在整个图像高度和50%宽度的图像上方进行2格划分

[英]Make 2 divs on top of image that is full image height and 50% width

Please please please help. 请请帮助。 I have a full width image slideshow, and I'm trying to have one div on the left which is 50% of the image width and 100% image height, and another div on the right that is 50% of the image width and 100% image height. 我有一张全角图片幻灯片,我想在左侧创建一个div,即图像宽度的50%和图像高度的100%,在右侧创建另一个div,即图像宽度的50%和100 %图像高度。 I can easily get the width properly, but I can't get the divs to cover the full image height, especially when i resize. 我可以轻松地正确获得宽度,但是无法获得div来覆盖整个图像高度,尤其是当我调整大小时。

JS FIDDLE JS菲德尔

 $(document).ready(function() { $(function(){ $('.fadein img:gt(0)').hide(); setInterval(function(){ $('.fadein :first-child').fadeOut() .next('img').fadeIn() .end().appendTo('.fadein');}, 4000); }); $(function () { $('.fadein img:gt(0)').hide(); $('.nextButton').on('click', function () { $('.fadein :first-child').fadeOut() .next('img').fadeIn() .end().appendTo('.fadein'); }); $('.previousButton').on('click', function () { $('.fadein :last-child').fadeIn() .insertBefore($('.fadein :first-child').fadeOut()); }); }); }); 
 body, html{ margin:0; padding:0; } .fadein { position:relative; width:100%; height:auto; } .fadein img { position:absolute; width: 100%; height: auto; } #slideshow{ position: relative; height: 200px; border: dashed pink; } #previous{ width:50%; height:100%; top:0; left:0; border:solid blue; position:absolute; } #next { width:50%; height:100%; border:solid green; position:absolute; top:0; right:0; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id ="slideshow"> <div class="fadein"> <img src="http://www.planwallpaper.com/static/images/518169-backgrounds.jpg"> <img src="http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg"> <img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg"> </div> <div id="previous" class="previousButton"></div> <div id="next" class="nextButton"></div> </div> 

I have updated your code in fiddle check it . 我已经在检查中更新了您的代码。
height:100vh; https://jsfiddle.net/ay5802hb/ https://jsfiddle.net/ay5802hb/

Try it and give feedback if this works for you. 尝试一下,如果有帮助,请提供反馈。

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

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