【问题标题】:Div class display:none not workingdiv类显示:没有不起作用
【发布时间】:2014-04-10 16:59:02
【问题描述】:

我是 CSS 新手,所以还是有点摸不着头脑......

我正在尝试在我的开发website底部添加一行图像

这适用于桌面浏览器,但我想在移动设备上隐藏除 Trustwave 徽标之外的所有内容。

我的主题是响应式的,以下代码在 jFiddle 中运行良好,但在我的网站上却不行。请有人指出我遗漏了什么吗?

我知道我需要将内联样式移到 CSS 文件中,但首先试图找出 display:none 无法正常工作的原因。

HTML:

<div id="ft">
<div class="ftI">
    <div class="ftT">
        <?php echo $this->getChildHtml('newsletter') ?>
        <?php echo $this->getChildHtml('cms_footer_links') ?>
    </div>
    <div class="ftB">
        <span class="copr"><?php echo $this->getCopyright() ?></span>
        <?php echo $this->getChildHtml('footer_links') ?>
    </div>
</div>
<?php /** ADD LOGOS TO FOOTER */ ?>
<div class="ftLogos" style="width:80%; height:56px; margin:0 auto;">
    <div class="ftFb" style="float:left; width:20%; text-align:center; margin:0 auto;"><img src="<?php echo $this->getSkinUrl() ?>images/logos/footer-facebook.png" alt="Find us on FaceBook" /></div>
    <div class="ftTw" style="float:left; width:20%; text-align:center; margin:0 auto;"><img src="<?php echo $this->getSkinUrl() ?>images/logos/footer-twitter.png" alt="Follow us on Twitter" /></div>
    <div class="ftSt" style="float:left; width:20%; text-align:center; margin:0 auto;"><img src="<?php echo $this->getSkinUrl() ?>images/logos/footer-stripe.png" alt="Secure Card Payments by Stripe" /></div>
    <div class="ftPp" style="float:left; width:20%; text-align:center; margin:0 auto;"><img src="<?php echo $this->getSkinUrl() ?>images/logos/footer-paypal.png" alt="Pay Securely by PayPal" /></div>
    <div class="ftTr" style="float:left; width:20%; text-align:center; margin:0 auto;"><script type="text/javascript" src="https://sealserver.trustwave.com/seal.js?style=normal"></script></div>
</div>

CSS(仅适用于小屏幕的部分):

.ftFb {display:none;}
.ftTw {display:none;}
.ftSt {display:none;}
.ftPp {display:none;}

我很高兴了解这里是否有更好的格式和提问方式:-)

谢谢,

【问题讨论】:

  • “我知道我需要将内联样式移到 CSS 中”真的吗?那么请这样做...
  • dev.sconchtextiles.co.uk为我工作
  • 我使用的是 1366x768 显示器,它真的不是手机……我在底部除了徽标之外没有看到任何图像……我错过了什么……?
  • 您的小屏幕媒体查询可能配置不正确。
  • 很奇怪 - 我可以在我的桌面浏览器上看到所有 5 个徽标,在我的移动浏览器上看到所有 5 个徽标(包括将我的桌面浏览器调整为移动大小)。我尝试了一个全新的移动浏览器来排除任何缓存问题。我希望移动用户只能看到 Trustwave 徽标(如果您可以看到所有 5 个徽标,则为右侧)

标签: html css


【解决方案1】:

您的问题似乎是您将其隐藏起来。您需要将其从 media=all 中删除

media="all"
.ftTw {
 display: none; 
}

使用 chrome 检查浏览 css。看起来您的媒体查询正在执行以下操作。因此,对于除 ftTr 之外的所有内容,它们都使用以下代码隐藏。

media="all"
@media screen and (min-width: 768px)
.ftPp {
display: none;
}
media="all"
.ftPp {
display: none;
}

我看到的唯一图标是 ftTr,它总是显示出来。其余的总是隐藏的。我建议查看您如何创建媒体 css。

【讨论】:

  • 对不起,我不明白。我的 3 个媒体查询是: 桌面:'@include media-query($mq-l) {}' 平板电脑:'@include media-query($mq-m) {}' 移动设备:无查询 我希望的图像显示在 .ftTr
  • 谢谢 - 我看不到,我只看到所有 5 个徽标,无论设备或屏幕大小如何,所以我一定有本地缓存​​问题,但奇怪的是它在所有浏览器上都为我做/设备
  • 可能需要检查并确保您没有按浏览器类型执行此操作。你可以用不同的方式来做,比如chrome,ff。
  • 它在 Firefox 和 Chrome 以及 Android 浏览器和智能手机上的 Chrome 移动版中对我来说表现相同。
  • 我也为你检查了 chrome,即 android。只显示 ftTr 图标和我检查的所有内容。您很可能遇到了缓存问题。
猜你喜欢
  • 1970-01-01
  • 2022-07-18
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多