javascript - jquery mobile 1.4.5 设置面板高度可能吗?

标签 javascript jquery css jquery-mobile panel

我正在制作一个仅移动的 jqm 元素。

我有两个面板,一组用于插入,另一组用于叠加。一个在左上角,另一个在右上角。

我的问题是可以将右侧面板设置为 100% 宽度(我已经这样做了)并将高度设置为 10-20% (40px-50px)。

这可以在不破坏任何功能的情况下完成吗?可以在 Css 中完成吗?我可以设置宽度但无法设置高度。

提前致谢!

最佳答案

自定义右侧或左侧面板,您需要更改 JQM 设置的 3 个 CSS 类。包含内容的动画、面板和面板的内部部分。更简单的方法是创建自定义叠加框。

演示 https://jsfiddle.net/bz649m86/

HTML

<div class="box"><a class="close">Close</a></div>

CSS

.box {
    position:fixed; // a fixed position is used for the box
    top:0; // placed at the top of the screen
    right:-100%; // with a minus position setting on the right side of the screen so its hidden from view
    background-color: blue;
    width: 100%; //with a width of the whole screen, but it can be any width
    display: block; //displayed in block format
    z-index: 999999; // above the header when in view
    overflow: hidden; // if you don't require scrolling within the box
    height:40px; // the height size required
//the transition settings are not needed but makes the animation of the panel much smoother.
    -webkit-transition: all .3s ease; 
    -moz-transition: all .3s ease;
    -ms-transition: all .3s ease;
    -o-transition: all .3s ease;
    transition: all .3s ease;
}

Jquery

// animate on click to bring the box in to view
    $(document).on("click", ".pannel", function () {
        $('.box').animate({
            'right': "0%"
        }, 300);
    })
// and out of view when closed    
    $(document).on("click", ".close", function () {
        $('.box').animate({
            'right': "-100%"
        }, 300);
    })

作为旁注,使用此方法,您可以在屏幕上的任何位置显示自定义面板(覆盖)。

在此演示中,框来自屏幕顶部

https://jsfiddle.net/Lqxp2ewb/

关于javascript - jquery mobile 1.4.5 设置面板高度可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29320110/

相关文章:

javascript - 修改javascript将网页字体颜色更改为黑色

javascript - 使用 Angular 在顶部添加行 - Xeditable

javascript - Firebase 实时数据库安全规则 - 检查其他节点

html - 如何滚动到固定导航的 anchor 链接

javascript - 解析错误: Unexpected token "" at EOF in a basic react . js文件

c# - 如何从JSON格式的DataSet中提取DataTable

jquery - 获取 html 表格指定列中的元素

javascript - 保持固定的 div 与另一个 div 的特定距离,即使在调整大小时也是如此

css - 如何使 Bootstrap 网格重叠

JavaScript cssText 在 Firefox 和 Opera 浏览器中无法正常工作