【问题标题】:CSS display property not working in mobile browsersCSS显示属性在移动浏览器中不起作用
【发布时间】:2017-10-19 16:49:16
【问题描述】:

http://phoenixchange.com/test/170518_TextTest.html 处的文档经过验证,并在“大多数”浏览器中按预期显示,但在移动 Safari 等浏览器中仍不显示。 (请参阅下面的编辑 8)谁能解释这个以及如何解决?

CSS

.hideaway {
    font-family: arial;
    font-style: italic;
    }
.hiddentxt {
    white-space: pre-wrap;
    letter-spacing: 0.1em;
    }
.hideaway .hiddentxt {
    display: none;
    }
.hideaway:hover .hiddentxt {
    display: inline;
    color: white;
    font-family: times;
    font-weight: normal;
    background: blue;
    }

HTML <p>Accusantium doloremque..odit aut fugit.<span class="hideaway"><br><span class="link normal">[more]</span> <span class="hiddentxt"><br> Interested ? Contact me for details ! </span></span></p>

....

编辑 8 代码 W3C 验证(不必要的 ; 字符,例如 <span class="link normal";> 已删除)。下面的答案只是在这篇文章中的错字。文档正确显示在:
手机:三星、Chrome、Firefox
桌面:Safari、Firefox、IE、Opera
但仍然不是在:
手机:Opera Mini、Safari
Safari mobile 和 Opera Mini 显然都是重要的移动浏览器,所以我真的希望任何代码都可以在这些浏览器上工作(即使用“当前千禧年”浏览器)。我没有成功找到对它们不起作用/在“当前千年”(移动)浏览器的安全 html/css 子集上不起作用的特定信息。

【问题讨论】:

  • 你试过使用 display:flex 吗?
  • 我没有。如果我理解,flex 指定隐藏元素的长度?不过这里的问题是元素根本没有:hover 更改。由于某种原因,浏览器无法识别其中的任何一个。编辑 - 我的错误! display:flex "将元素显示为块级弹性容器。CSS3 中的新功能"。不过,我在这里遇到的问题是没有识别,而不是错误的行为。
  • 但是谢谢!!了解该功能很有用!我发布的页面测试了排版和布局。内联隐藏文本不是为它在那里使用的情况而设计的,但它提供了一种查看它如何工作的方法(或者在这种情况下不工作!)。

标签: css mobile responsive-design display


【解决方案1】:

<span class="hideaway" 缺少 >

这就是为什么您应该始终使用空格和编码程序(而不是记事本)!

.hideaway {
    font-family: arial;
    font-style: italic;
    }
.hiddentxt {
    white-space: pre-wrap;
    letter-spacing: 0.1em;
    }
.hideaway .hiddentxt {
    display: none;
    }
.hideaway:hover .hiddentxt {
    display: inline;
    color: white;
    font-family: times;
    font-weight: normal;
    background: blue;
    }
<p>
    Accusantium doloremque..odit aut fugit.
    <span class="hideaway">
        <br>
        <span class="link normal";>
            [more]
        </span> 
        <span class="hiddentxt">
            <br> 
            Interested ?  Contact me for details ! 
        </span>
    </span>
</p>

https://drivenotepad.github.io/编辑和检查代码

You could use the title attribute

title 属性指定有关元素的额外信息。

当鼠标移到元素上时,该信息通常显示为工具提示文本。

&lt;p title="Interested ?  Contact me for details !"&gt;[more]&lt;/p&gt;

一旦他们将鼠标悬停在带有标题的元素上,这将显示更多信息。

【讨论】:

  • FF 可能会自动更正错误并假设您打算结束标签,但我建议您修复此问题。并使用空格!
  • 谢谢。这个错误是我在此处复制粘贴的代码中的错字。在页面上存在标签。我已经编辑了 OP,但保留了代码的格式,因为我正在使用 white-space: pre-wrap;
  • 感谢对 title 属性的引用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-18
  • 2015-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-28
相关资源
最近更新 更多