【问题标题】:Problems with 100% viewport width in mobile?移动设备中 100% 视口宽度的问题?
【发布时间】:2016-08-08 13:31:24
【问题描述】:

我在移动设备中的 2 个页面没有达到 100% 的宽度,您可以看到它here

我的代码中有<meta name="viewport" content="width=device-width" />,我尝试了它的各种变体。问题可能出在我的pages.phpfile 中,因为其余页面都是自定义模板?

这是我的 page.php 代码:

<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 */

get_header(); ?>

<div id="primary" class="content-area">
    <div id="content" class="site-content" role="main">
        <?php while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content' ); ?>

        <?php endwhile; // end of the loop. ?>
    </div><!-- #content .site-content -->
</div>

<?php get_footer(); ?>

CSS:

#content {
  margin: 0 auto;
  max-width: 51em;
  background: none;
  float: none;
  margin: 0 auto;
  padding: 0;
}

#primary {
  width: 100%;
}

我不知道我是否遗漏了一些与 wordpress 相关的内容,或者弄乱了我的代码(我是编码的初学者),或者是什么。很困惑,因为我的其他页面工作正常,而且我在代码中看不到任何导致其宽度变窄的内容。

*btw - 尚未弄清楚移动设备中的导航,但您可以通过查看链接看到它在其他页面中有效: Home.

【问题讨论】:

    标签: php html css wordpress


    【解决方案1】:

    一切都正确,但我看到了 scroll,因为您的 footer 得到了一些 non-responsive 代码。

    在此页面中:

    http://melmencarelli.com/about/

    首先,将box-sizing: border-box; 添加到#footer-container 并像这样设置width: 100%

    #footer-container {
        width: 100%;
        margin: 0 auto;
        padding: 30px;
        box-sizing: border-box;
    }
    

    然后,将width: 100% 设置为.footer-info,如下所示:

    .footer-info {
        float: left;
        width: 100%;
        margin-bottom: 25px;
    }
    

    在此页面中:

    http://melmencarelli.com/

    执行上述指令,然后将width: 100% 设置为:

    @media only screen and (max-width: 1023px) and (min-width: 0px)
    @media only screen and (max-width: 1023px) and (min-width: 0px)
    @media only screen and (max-width: 500px) and (min-width: 0px)
    html input[type="button"] {
        font-size: 14px;
        padding: 20px 20px;
        width: 100%;
    }
    

    我也看到了这个:

    <div class="home-button">
    <a href="http://melmencarelli.com/mentoring/">
    <input type="button" value="HOW WE WORK TOGETHER">
    </a>
    </div>
    

    我建议你使用这个:

    <div class="home-button">
    <a href="http://melmencarelli.com/mentoring/">
    <button>HOW WE WORK TOGETHER</button>
    </a>
    </div>
    

    好吧,一切看起来都不错!

    【讨论】:

    • 太棒了,谢谢伙计。所以我做出了改变,但我仍然在那个关于页面上得到疯狂的动作。我似乎无法在此处链接屏幕截图,但在 Iphone 5 下的 chrome 检查器中它会显示它。有什么建议吗?
    • 欢迎您。将您的屏幕截图添加到第一个帖子(问题)然后让我知道。 @MelanieMencarelli
    • 看起来这是一个chrome 问题.. 不知道,但仍在尝试找出。但我在iphone 6 上查看了你的网站,看起来不错,See@MelanieMencarelli |如果我发现 chrome 问题,请告诉您。
    • 但我看到了你的导航。我猜还有一个viewport 问题。您可以在Screenfly 中查看您的网站
    • 哦,是的,你是对的!奇怪,一定是有什么东西修复了它,因为在我的 iphone 中它看起来和在 chrome 中的一样。最后一个问题:为了使页面对移动设备友好(也就是不像在桌面上查看一样显示),这些只是媒体查询更改还是与视口宽度代码有关(不知道这里的适当术语)?编辑:啊哈,是的,你在我点击发送之前回答了。我去看看。
    猜你喜欢
    • 1970-01-01
    • 2015-05-22
    • 2014-09-07
    • 2014-09-08
    • 1970-01-01
    • 2020-06-25
    • 1970-01-01
    • 2011-10-29
    • 2015-05-07
    相关资源
    最近更新 更多