HTML CSS 布局在 iPad 横向模式下缩小?

发布于 2024-11-09 00:35:35 字数 170 浏览 0 评论 0原文

我正在为iPad制作一个布局,布局的宽度是950px,当我进入横向模式时,我没有得到任何水平滚动条(实际上我应该有,因为布局的宽度以像素为单位固定,950px而不是786px)全部都是很好,但顶部标题栏的高度正在缩小。

我做错了什么。我希望我的布局在横向模式下不应该缩小。每个元素应该具有与纵向模式相同的高度。

I'm making a layout for iPad and width of layout is 950px and when I go into landscape mode I'm not getting any horizontal scroll bar ( which actually I should have because layout's width is fixed in pixel which 950px not 786px) all is fine but top title bar's height is shrinking.

What I'm doing wrong. I want my layout should not be shrinking in landscape mode. each element should have same height like portrait mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

枯叶蝶 2024-11-16 00:35:35

我怀疑 viewport 元点击可以调整您网站的大小。尝试将初始值固定为 1,最小值固定为最大值。

<meta name="viewport" content="width=950, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

https://developer.apple.com/库/存档/文档/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

I suspect the viewport meta tap to resize your site. Try to fix the scale to 1 in the initial, maximum in minimum values.

<meta name="viewport" content="width=950, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

苹果你个爱泡泡 2024-11-16 00:35:35

我不知道您是否遇到这种情况,但 iOS 上存在一个错误,即在纵向和横向模式之间切换时比例会发生变化。请参阅 http://www.blog .highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/

您可以按如下方式修复它:

将此元标记添加到 HTML 文档的头部:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

并将此 JavaScript 添加到页面 - 参见 https://gist.github.com/90129

(function(doc) {

var addEvent = 'addEventListener',
    type = 'gesturestart',
    qsa = 'querySelectorAll',
    scales = [1, 1],
    meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

function fix() {
    meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
    doc.removeEventListener(type, fix, true);
}

if ((meta = meta[meta.length - 1]) && addEvent in doc) {
    fix();
    scales = [.25, 1.6];
    doc[addEvent](type, fix, true);
}

}(document));

I don't know if this is what is happening for you, but there is a bug on iOS whereby the scale changes when switching between portrait and landscape mode. See http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/

You can fix it as follows:

Add this meta tag to the HTML document's head:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

And add this JavaScript to the page - see https://gist.github.com/90129

(function(doc) {

var addEvent = 'addEventListener',
    type = 'gesturestart',
    qsa = 'querySelectorAll',
    scales = [1, 1],
    meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

function fix() {
    meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
    doc.removeEventListener(type, fix, true);
}

if ((meta = meta[meta.length - 1]) && addEvent in doc) {
    fix();
    scales = [.25, 1.6];
    doc[addEvent](type, fix, true);
}

}(document));
谢绝鈎搭 2024-11-16 00:35:35

在 webkit 设备 (Android/iOS) 上,您可以在正文上使用此 CSS,以防止文本在方向更改(旋转)后调整大小。我花了一段时间才找到它。希望它能帮助其他人解决这个奇怪的功能。

<style>
body {
     -webkit-text-size-adjust: none;
}
</style>

On webkit devices (Android/iOS) you can use this CSS on the body to prevent text from resizing after an orientation change (rotation). It took me a while to track it down. Hope it helps others with this odd feature.

<style>
body {
     -webkit-text-size-adjust: none;
}
</style>
谁对谁错谁最难过 2024-11-16 00:35:35
<link rel="stylesheet" media="handheld" href="css/handheld.css?v=2">

这也可能有帮助

<link rel="stylesheet" media="handheld" href="css/handheld.css?v=2">

This can be also helpful

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文