[英]Body media query doesn't work
I have a navigation bar which has padding to allow content to display under the navigation bar. 我有一个导航栏,该导航栏具有填充以允许内容显示在导航栏下方。 For mobiles I want to lessen the padding but the media query doesn't seem to work. 对于手机,我想减少填充,但是媒体查询似乎不起作用。 Any ideas to why? 有什么想法吗?
Example: 例:
body{ padding-top: 70px; } pt{ color: white; background-color: black; top: 0px; position: absolute; } @media only screen and (max-width: 767px) { .body { padding-top: 0px; } }
<body> <p class="t"> This is my pretend navbar woo. </p> <p> hello </p> </body>
You're doing .body
instead of body
. 你正在做.body
而不是body
。 By using .body
, the CSS is searching for an element with class="body"
, instead of an element <body>
. 通过使用.body
,CSS正在搜索带有class="body"
的元素,而不是元素<body>
。 Simple fix: 简单修复:
@media only screen and (max-width: 767px) {
body {
padding-top: 0;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.