【问题标题】:iPhone 6/6 Plus cutting off content with 100% widthiPhone 6/6 Plus 以 100% 宽度截断内容
【发布时间】:2023-03-07 20:25:01
【问题描述】:

我正在尝试为一些通用文件共享实用程序的链接创建一个网页。我遇到的问题是在 iPhone 6/6 Plus 上它会切断右侧的内容。我已将其容器的宽度设置为 100%,并且其中包含的 div 设置为显示 inline-block 以便它们可以居中对齐。为什么 iPhone 6/6 Plus 会切断它而不是把它扔到下一行。我已验证旧版本的 iOS、Android 和台式电脑似乎没有此问题。

视口:

<meta name="viewport" content="width=device-width, maximum-scale=1, user-scalable=no" />

CSS:

html {  
    background: url('images/background.png') no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
body, html
{
    margin: 0;
    padding: 0;
    font-family: 'PT Sans';
}
.box
{
    height: 140px; 
    width: 150px;
    text-align: center;
    display: inline-block;
}
.box img 
{
    width: 90px;
    height: 90px;
    margin-bottom: 10px;
}
.box a:link, .box a:visited, .box a:hover
{
    text-decoration: none;
    color: #fff;
}
.title
{
    font-size: 48pt; 
    color: #fff;
    font-weight: lighter;
}
a:link, a:visited, a:hover
{
    text-decoration: none;
}
.subtitle
{
    color: #fff; 
    display: block; 
    margin-bottom: 20px;
}

@media (max-width:600px) { 
    .title
    {
        font-size: 22pt;
    }
    .subtitle
    {
        margin-bottom: 5px;
    }
}

HTML:

<div>
    <span style="position: absolute; top: 5px; width: 100%; margin: 0; text-align: center; color: #fff; font-size: 24pt; z-index: 2; display: block;">----</span>
    <div style="width: 100%; height: 60px; background-color: black; opacity: .3;"></div>
    <div style="text-align: center; margin: 15px;"><span class="title" >Share from the cloud.</span><br /><span class="subtitle">Select you prefered service to access your media and information from the web.</span></div>
    <div style="margin: 0 auto; text-align: center; max-width: 1200px; overflow: hidden; align-items: center">
        <div class="box"><a href="http://www.dropbox.com"><img src="images/dropbox.png" alt="" /><br />Dropbox</a></div>
        <div class="box"><a href="http://onedrive.live.com"><img src="images/one_drive.png" alt="" /><br />OneDrive</a></div>
        <div class="box"><a href="http://www.sugarsync.com"><img src="images/sugarsync.png" alt="" /><br />SugarSync</a></div>
        <div class="box"><a href="http://www.google.com/"><img src="images/google.png" alt="" /><br />Google</a></div>
        <div class="box"><a href="http://www.google.com/drive"><img src="images/google_drive.png" alt="" /><br />Google Drive</a></div>
        <div class="box"><a href="http://www.facebook.com"><img src="images/facebook.png" alt="" /><br />Facebook</a></div>
        <div class="box"><a href="http://instagram.com"><img src="images/instagram.png" alt="" /><br />Instagram</a></div>
        <div class="box"><a href="http://flickr.com"><img src="images/flickr.png" alt="" /><br />Flickr</a></div>
        <div class="box"><a href="http://www.box.com"><img src="images/box.png" alt="" /><br />Box</a></div>
    </div>
</div>

【问题讨论】:

    标签: html ios css iphone responsive-design


    【解决方案1】:

    iPhone6 的最大宽度为 375px。

    http://mydevice.io/devices/

    在@media 标签中更改外部 div 的最大宽度(您使用 max-width: 1200px 设置内联样式的那个)。如果你创建一个单独的类会更容易。

    【讨论】:

    • 感谢您的建议,但这不起作用。我仍然需要清理我的代码,我只是想弄清楚为什么它不起作用。但是将其更改为一个类并使用媒体查询将其最大宽度设置为 370 像素,但仍将其切断。我认为尝试在没有查询的情况下更改最大宽度以确保我的查询是正确的。即使我在没有查询的情况下应用到元素,它也不起作用,它仍然允许元素流过边界。
    • 很抱歉,它没有帮助。这里还有一些建议:1)改变显示:inline-block;显示:内联表; (或桌子)有时会为我解决定位问题。 2) 对于最外层的 div(样式为空),尝试将该宽度设置为 100% 或为其创建一个最大宽度。
    猜你喜欢
    • 1970-01-01
    • 2016-06-07
    • 2014-12-20
    • 1970-01-01
    • 2014-11-03
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多