【问题标题】:How To Change Font Color on Mobile Res如何在 Mobile Res 上更改字体颜色
【发布时间】:2020-10-25 20:06:54
【问题描述】:

我很难解决我的网站的这个小问题,所以正文文本在桌面上显示为白色,这很好,但是当我使用较小的设备时,我不希望文本显示白色,因为它与白色背景一起折叠并且您无法阅读文本。如何使用 CSS 或 HTML 将其更改为移动版本的另一种颜色?

This Is How It Shows On Desktop

This Is How It Shows On Smaller Screens (Phones, Tablets, etc)

来自 Stackoverflow 的编辑(不起作用)

CSS:

@media only screen and (max-width: 600px) {
    .mob1 {
     color: #ffffff;
   }
  }
  
@media only screen and (min-width: 600px) {
    .mob1 {
     color: #000000;
   }
  }

HTML:

<p style="color: aliceblue;" class="custom-article wow fadeInDown" data-wow-delay=".2s"><span class="mob1">Changed Text</span></p>
  • 我尝试将 mob1 添加到 p 类,也没有成功。

【问题讨论】:

    标签: html jquery css saas


    【解决方案1】:

    尝试使用媒体查询。

    @media only screen and (max-width: 600px) {
      body {
        background-color: lightblue;
      }
    }
    

    更多详情:https://www.w3schools.com/css/css_rwd_mediaqueries.asp

    【讨论】:

    • 所以,我想改变文本颜色,而不是背景颜色。 (我也可以加课吗??)
    • 这只是示例代码。您可以添加自定义类和 css 属性。 @media only screen and (max-width: 600px) { .my-text { color: lightblue; } }
    【解决方案2】:

    试试这个

    在 html 文件上,如果它是 p 元素,或者它是任何类型的文本元素,

    <p class="colourTest">TEXT</p>
    
    in the css file: 
    
    //for screens smaller then mobile
    @media only screen and (max-width: 600px) {
      .colourTest {
       text-color: black;
    }
    }
    
    //for screens bigger then mobile
    @media only screen and (min-width: 600px) {
      .colourTest {
       text-color: white;
    }
    }
    

    【讨论】:

    • text-color 在 CSS 中实际上只是 color
    • @tacoshy 没用,我试过没有文字颜色。什么都没有发生。
    • @user14518181 您不能在 p 样式中指定颜色,它将覆盖 css。把它拿出来,像这样把类“mob1”放出来,

    猜你喜欢
    • 2010-10-07
    • 2011-11-13
    • 1970-01-01
    • 2014-04-28
    • 2015-05-18
    • 2011-05-20
    • 1970-01-01
    • 2015-03-19
    相关资源
    最近更新 更多