[英]How to make a div fit on my screen height?
I have some modal divs to display images or videos, but when I expand these images it gets higher than my screen size:我有一些模态 div 来显示图像或视频,但是当我展开这些图像时,它会高于我的屏幕尺寸:
My code:我的代码:
<div class="modal fade" id="showMedia" tabindex="-1" role="dialog"
aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered"
role="document">
<div class="modal-content">
<div class="modal-body">
<div id="media" class="carousel slide" data-ride="carousel"
data-interval="false">
<div class="carousel-inner">
<div th:each="inst, iStat : ${instances}"
th:class="'carousel-item text-center ' + ${iStat.index == 0 ? 'active' : ''}">
<button type="button" class="close" data-dismiss="modal"
aria-label="Fechar">
<span aria-hidden="true">×</span>
</button>
<video
th:if="${inst.type} eq ${T(br.com.macrosul.stetho.entity.study.InstanceTypes).VIDEO}"
style="width: 100%;" controls preload="none">
<source
th:src="@{'/instances/' + ${inst.id} + '/file' + ${folder != null ? '?folder=' + folder.id : ''}}"
type="video/mp4">
</video>
<img
th:if="${inst.type} eq ${T(br.com.macrosul.stetho.entity.study.InstanceTypes).IMAGE}"
th:class="rs" alt="" style="width: 100%;"
th:src="@{'/instances/' + ${inst.id} + '/thumbnail' + ${folder != null ? '?folder=' + folder.id : ''}}"
th:data-src="@{'/instances/' + ${inst.id} + '/file' + ${folder != null ? '?folder=' + folder.id : ''}}">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I've set width of image as 100% expecting it to fit on the screen size, but it doesn't happen.我已经将图像的宽度设置为 100%,希望它适合屏幕尺寸,但它没有发生。
Setting the width means that if the image is taller than it is wider it will be bigger than the page.设置宽度意味着如果图像的高度大于宽度,它将比页面大。 You'd be best setting max-height:100vh
(100% of the viewport height)您最好设置max-height:100vh
(视口高度的 100%)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.