简体   繁体   中英

Show/Hide a div according to screen size HTML/CSS

Hi I created my first React Project and I want to hide this 'side-menu' section in mobile screens. Is there a way to do this using css?

<div className='side-menu'>
   <SiderComponent />
</div>

If you want to hide this div in all the devices that have a max-width of 768px, just use this,

 @media (max-width: 768px){.side-menu { display: none; } }

at the same time if you want to hide a div on large screens (width is larger than 768px), use the below one

 @media (min-width: 768px){.your-class { display: none; } }


You can use media queries like that:
 @media screen and (max-width: ...px){.side_menu{ display: none; } }

https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries

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