简体   繁体   English

CSS-不应用媒体查询

[英]CSS - Not applying media query

I wrote media query for my HTML code, but not applying. 我为我的HTML代码编写了媒体查询,但没有应用。 I have to show my text in center in small screen. 我必须在小屏幕的中央显示我的文字。

 @media(max - width: 400 px) { h1 { text - align: center; } } 
 <h1>Search for a Doctor or Care Provider</h1> 

How to fix? 怎么修?

The problem that @Zvezdas1989 is removing is that you had a space between 400 and px, they need to be together, just like the max-width and the text-align . @ Zvezdas1989消除的问题是,您有400到px之间的空格,它们必须在一起,就像max-widthtext-align

@media(max-width: 400px) {
    h1 {
      text-align: center;
    }
}

So that will fix the problem. 这样就可以解决问题。

It's not applying because of the spaces, you need to remove those in order to make it valid: 由于空格,它不适用,您需要删除那些空格以使其有效:

 @media (max-width: 400px) { h1 { text-align: center; } } 
 <h1>Search for a Doctor or Care Provider</h1> 

You need to remove the spaces, like this: 您需要删除空格,如下所示:

 @media (max-width: 400px) { h1 { text-align: center; } } 
 <h1>Hello Friends</h1> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM