作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 PrimeFaces 和 BootsFaces 库。我在 bootsfaces 模态中有一个小表格。该表格用于更改系统参数,并且对于一个特定参数有一个 <p:keyboard />
改变它的值(value)。我的问题是,在超小型设备中, Bootstrap 模式不允许水平滚动,并且键盘未显示完整:
当视口(viewport)小于 510px 时,键盘默认没有响应,所以我在超小屏幕上默认将其调整为 436px。我想在模式上进行水平滚动只是为了看到完整的键盘,但只有当我打开模式时。
这是我根据屏幕大小调整键盘的 javascript 函数:
$(document).on('click', '.inpKeyboard', function() {//- The input text has a class called 'inpKeyboard'
if ($(window).width() <= 505) {//- Small screen
$('#keypad-div').css('width', '436px');
$('#keypad-div').css('left', '0px');
//$('.modal-open').css('overflow-x', 'auto');
}
$('#keypad-div').css('z-index', '2000');
});
如有任何帮助,我们将不胜感激。谢谢。
最佳答案
多棒的拼图啊! :) PrimeFaces 在 JavaScript 中计算键盘窗口的大小并将其存储为内联样式。所以解决这个问题的线索是添加一个超时,就像这样:
<script>
$(document).on('click', '.hasKeypad', () => {
$('#keypad-div').css('z-index', '2000');
if (!(window.width > 505)) { // JSF (i.e. XML) doesn't accept the less-than-operator
// add a timeout to make sure the code is executed after PrimeFaces did its magic
setTimeout(() => {
// set a fixed with
$('#keypad-div').css('width', '436px');
// add the horizontal scrollbar
$('#keypad-div').css('overflow-x', 'auto');
// increase the height to make space for the scrollbar
$('#keypad-div').css('height', '180px');}
,1);
}
});
</script>
<!-- set a minimum width for the keyboard rows -->
<!-- (otherwise the key overflow to the next row) -->
<style>
@media screen and (max-width: 504px) {
.keypad-row {
min-width:470px;
}
}
</style>
关于css - 使 bootsfaces 模态水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50651003/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!