简体   繁体   中英

Why does display:none not work here?

I think the problem is that #header img does not work.

 #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

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

Did you mean #logo instead of #header ? You're also missing a trailing semi-colon at the end of padding: 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元素。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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