【问题标题】:jquery mobile device orientation change not resizing text areajquery移动设备方向更改未调整文本区域大小
【发布时间】:2012-02-03 00:45:07
【问题描述】:

我正在尝试找出一种在设备旋转时使用 JQM 调整文本区域大小的方法。基本上,我有一个加载时看起来不错的文本区域,无论是纵向还是横向,但是当设备旋转时,它不会调整大小。下面是代码的一些样子:

.message-entry{
   margin-left:10px;
   margin-right:0;
   margin-bottom:-20px;
}

和 HTML:

 <footer data-role="footer" id="footer" data-theme="b" data-position="fixed">               
            <label class="label-message-entry" for="chatMessageEntry">Enter a message:</label>
            <textarea rows="8" name="textarea" class="message-entry" id="chatMessageEntry"></textarea>
            <a id="chatReplyButton" class="reply-button" data-role="button" data-icon="plus">Reply</a>              
        </footer> <!--end footer--> 

然后是orientationchange事件:

$(window).bind( 'orientationchange', function(e){
        var newWidth = $(window).width();
        $('.message-entry').css({'width':newWidth + 'px'});     
});

有什么想法吗?谢谢!

【问题讨论】:

    标签: javascript jquery css jquery-mobile


    【解决方案1】:

    您是否尝试过在媒体查询中为 textarea 指定最小宽度?

    @media all and (max-width: 480px) and (min-width: 321px){
        .message-entry{
            min-width:470px;
        }
    }
    @media all and (max-width: 320px){
        .message-entry{
            min-width:310px;
        }
    }
    

    【讨论】:

    • 那是什么语法?我只是在使用 JS、HTML 和 CSS 的浏览器中正确执行此操作
    • 另外,iPad 和其他东西呢?设备尺寸永远不会保持不变,所以你不能硬编码最小/最大宽度......
    • 好的,您有问题的实时版本要测试吗?
    猜你喜欢
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多