【问题标题】:Add different version of class for mobile browsers为移动浏览器添加不同版本的类
【发布时间】:2015-07-20 03:34:46
【问题描述】:

我正在编辑一个 Wordpress 主题,并在 Bootstrap 的 <div class="well"> 中添加了一个内容框。我不得不删除内容框的padding-bottommargin-bottom,因为在桌面上显示内容框后,内容框中有很多空间。虽然删除填充和边距在桌面上效果很好,但它在移动设备上溢出。图片如下:-

在 PC 上,它看起来像这样:-

不管怎样,这是<div class='well'>里面的内容框:

.site-content article {
    word-wrap: break-word;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
    padding-bottom:auto;
    margin-bottom:auto;
}

【问题讨论】:

    标签: html css wordpress twitter-bootstrap


    【解决方案1】:

    在 wordpress 中,您有一个 php 函数,如果 it's mobile wp_is_mobile() 则返回 true,然后您可以将所需的类放入 HTML。

    然后 wordpress 将 .mobile 类添加到您的 body,这样您就可以放置不同的填充,如果有 .mobile 类或没有。

    【讨论】:

    • 你能解释一下吗??
    • 默认情况下,WP 具有可用于移动设备的功能,例如,如果您可以在移动设备上向 HTML 代码添加类:<div class="one <?php if ( wp_is_mobile ) echo 'mobile'; ?>">。但是如果你不能使用这个功能,WP,当你在手机上时,在你的body中添加.moble这个类:<body class="... mobile">
    【解决方案2】:

    尝试在您的 CSS 中添加带有媒体查询的 padding-bottom :

    @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
    
     Your content box class { 
         padding-bottom: ;
         margin-bottom: ;
    
     }
    

    }

    【讨论】:

    【解决方案3】:

    仅当文档宽度小于 500 像素时才更改边距和内边距:

    @media screen and (max-width: 500px) {
        .site-content article {
           padding-bottom:0px;
           margin-bottom:0px;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-10-23
      • 1970-01-01
      • 2018-09-04
      • 2011-04-27
      • 2015-04-22
      • 1970-01-01
      • 2011-07-14
      • 1970-01-01
      • 2014-02-11
      相关资源
      最近更新 更多