简体   繁体   English

为什么display:none在这里不起作用?

[英]Why does display:none not work here?

I think the problem is that #header img does not work. 我认为问题是#header img不起作用。

 #header img { border-style: solid; border-color: #000000; border-width: 5px; padding: 5px } @media only screen and (max-width: 840px) { #header img { display:none; } } 
 <h1><a href="index.html" id="logo"><img src="images/platzhalter.jpg" </a></h1> 

 #header img { border-style: solid; border-color: #000000; border-width: 5px; padding: 5px } @media only screen and (max-width: 840px) { #header img { display:none; } } 
 <h1><a href="index.html" id="logo"><img src="images/platzhalter.jpg" </a></h1> 

You don't have #header img, try to change #header with #logo 您没有#header img,请尝试使用#logo更改#header

@media only screen and (max-width: 840px) { #logo img { display:none; } 

Did you mean #logo instead of #header ? 您是说#logo而不是#header吗? You're also missing a trailing semi-colon at the end of padding: 5px . 填充末尾您还缺少尾随的分号:5px

This works for me: 这对我有用:

#logo img 
{
    border-style: solid;
         border-color: #000000;
         border-width: 5px;
         padding: 5px;
}

@media only screen and (max-width: 840px) { #logo img { display:none; } } 

选择器#header img与代码段中的任何元素都不匹配,因为不存在具有id属性值header元素。

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

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