[英]remove scroll bar in bootstrap modal
<span class="education"style="font-size:170%;line-height:150%;"> Education
<br>
<small style=" color:gray;font-size:60%;">
Indian Institute of Managment,2009-2011
</small>
<br>
<small style=" color:gray;font-size:60%;"> Indian Institute of
Technology,2004-2008
</small>
<br>
<a data-toggle="modal" href="#education" style="float:right;font-size:60%;">
<small> Edit
</small>
</a>
<div class="modal fade " id="education">
<div class="modal-dialog ">
<div class="modal-content light">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
</button>
<h4 class="modal-title">Education
</h4>
</div>
<div class="modal-body">
<form>
<fieldset>
<label for="post-graduation">post-graduation:
</label>
<input type="text" name="post-graduation" id="inputbox"
class="text ui-widget-content ui-corner-all" />
<label for="graduation">graduation:
</label>
<input type="text" name="graduation" id="inputbox"
class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</span>
It is my code. 这是我的代码。 I want a modal when I click on edit button. 当我点击编辑按钮时,我想要一个模态。 The modal was appear in my page and disappear when I click on close button. 模态出现在我的页面中,当我点击关闭按钮时消失。 But with modal it also show scroll bar. 但是使用模态它还会显示滚动条。 How can I remove scrollbar from my code? 如何从代码中删除滚动条?
In bootstrap 3 the CSS puts the second bar in there (modal class). 在bootstrap 3中,CSS将第二个条放在那里(模态类)。 You can change it like: 你可以改变它:
.modal {
overflow-y: auto;
}
You should hide the scroll from the bootstrap class and then remove the margin-right
of the body
. 您应该隐藏引导类的滚动,然后删除body
margin-right
。
Here the css
code: 这里是css
代码:
#modalElementId
{
overflow: hidden;
}
and in the show.bs.modal
event: 并在show.bs.modal
事件中:
$('#modalElementId').on('show.bs.modal', function () {
$('body').css("margin-right", "0px");
});
.modal-open{
margin-right:0px !important;
}
you can set height for modal body 你可以设置模态体的高度
.modal-body {
max-height: 600px;
}
Your need remove the class
modal-open
in the body
, check: 你需要删除body
中的class
modal-open
,检查:
$('#modalElementId').on('hidden.bs.modal', function (e) {
$('body').removeClass('modal-open');
});
In my case I want to display an image on full screen so to achieve this I have to remove the modal padding(to display it over the scrollbar) and also adding some CSS. 在我的情况下,我想在全屏显示图像,所以为了实现这一点,我必须删除模态填充(以显示它在滚动条上),还添加一些CSS。 Example: 例:
<!-- Image Modal -->
<div class="modal fade p-0" id="zoomImageModal" tabindex="-1" role="dialog" aria-labelledby="zoomImageModal"
aria-hidden="true">
<div class="modal-dialog modal-full" role="img">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<div class="m-auto">
<img class="img-fluid" src="{{zoomPathImage}}" alt="zoomPathImage" [title]="zoomPathImage">
</div>
</div>
</div>
</div>
Style: 样式:
.modal-full {
min-width: 100%;
margin: 0;
}
.modal-full .modal-content {
min-height: 100vh;
}
Note: I am using Bootstrap4 注意:我使用的是Bootstrap4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.