Set bootstrap modal body height by percentage(按百分比设置引导模态体高度)
问题描述
我正在尝试制作一个带有正文的模式,当内容变得太大时会滚动.但是,我希望模态能够响应屏幕尺寸.当我将最大高度设置为 40% 时,它没有效果.但是,如果我将 max-height 设置为 400px,它会按预期工作,但没有响应.我确定我只是错过了一些简单的东西,但我似乎无法让它发挥作用.
I am trying to make a modal with a body that will scroll when the content becomes too large. However, I want the modal to be responsive to the screen size. When I set the max-height to 40% it has no effect. However, if I set the max-height to 400px it works as expected, but is not responsive. I am sure I am just missing something simple, but I can't seem to get it to work.
这是一个示例
不起作用:
.modal-body {
max-height:40%;
overflow-y: auto;
}
作品:
.modal-body {
max-height:400px;
overflow-y: auto;
}
推荐答案
这对我有用
.modal-dialog,
.modal-content {
/* 80% of window height */
height: 80%;
}
.modal-body {
/* 100% = dialog height, 120px = header + footer */
max-height: calc(100% - 120px);
overflow-y: scroll;
}
小提琴:http://jsfiddle.net/mehmetatas/18dpgqpb/2/
这篇关于按百分比设置引导模态体高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:按百分比设置引导模态体高度
基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
