Div show/hide media query - mobile

What code can I use to make a particular div show only if on a mobile width?
I have a 100% width full div at the top of my screen, would like it to only show when the device is specified as a mobile width.

I'm not sure, what you mean as the 'mobile width'. But in each case, the CSS #media can be used for hiding elements in the screen width basis. See some example:
<div id="my-content"></div>
...and:
#media screen and (min-width: 0px) and (max-width: 400px) {
#my-content { display: block; } /* show it on small screens */
}
#media screen and (min-width: 401px) and (max-width: 1024px) {
#my-content { display: none; } /* hide it elsewhere */
}
Some truly mobile detection is kind of hard programming and rather difficult. Eventually see the: http://detectmobilebrowsers.com/ or other similar sources.

It sounds like you may be wanting to access the viewport of the device. You can do this by inserting this meta tag in your header.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
http://www.w3schools.com/css/css_rwd_viewport.asp

Small devices (landscape phones, 576px and up)
#media (min-width: 576px) {
#my-content{
width:100%;
}
// Medium devices (tablets, 768px and up)
#media (min-width: 768px) {
#my-content{
width:100%;
}
}
// Large devices (desktops, 992px and up)
#media (min-width: 992px) {
display: none;
}
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) {
// Havent code only get for more informations
}

Related

React-boostrap NavBar FormControl and Buttons how to control left alignment and size in fluid layout

I learn rectjs and use the react-bootstrap NavBar. I use the suggest breakpoints from Media Queries docs and it looks like this:
Here is my Media Queries breakpoints:
// Extra small devices (portrait phones, less than 576px)
#media (max-width: 575.98px) { ... }
// Small devices (landscape phones, 576px and up)
#media (min-width: 576px) and (max-width: 767.98px) { ... }
// Medium devices (tablets, 768px and up)
#media (min-width: 768px) and (max-width: 991.98px) { ... }
// Large devices (desktops, 992px and up)
#media (min-width: 992px) and (max-width: 1199.98px) { ... }
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) and (max-width: 1920px) {
I made a CodeSandbox
NOTE: set browser window to 100% zoom in the CodeSandbox for this to work!
My problem is when I resize window and get under width 905px. Then I can't fine grain control layout in css so layout starting to wrap:
This is how it should look:
Under 905px toggle button jumps down:
Under 758px it looks even more bad
I try to change the css:
.container-fluid { // THIS IS LOGO IMAGE
.navbar-brand {
max-width: 37%;
}
}
.form-inline { // THIS IS THE SEARCH INPUT
width: 80%;
}
The problem is I think that I can't move the SEARCH INPUT and the buttons to the left as the screen width gets lesser. Changing the form-inline width to lets say 40px cuts it of only on the right side.
Any advice is helpful thanks?
Moving the button to the left on this image would do the trick I guess but how?

React-icons responsive size

How can I make react-icons icons size smaller for mobile? I understand pixel is not a good approach, but how should I do it?
import { FaSearch, FaFacebook, FaInstagram, FaUserCog, FaUserTimes } from "react-icons/fa";
<FaSearch
color="#023373"
size="30px" />
You can use #media query in your case. Add a class to your icon component and write media query for mobile device width.
<FaSearch color="#023373" className="SearchIcon" />
In your CSS, do this
.SearchIcon{
font-size: 40px;
}
#media only screen and (max-width: 400px) {
.SearchIcon {
font-size: 20px;
}
}
I created a working example using Stackblitz
Here's a list of all the #media queries for different device widths.
/* Extra small devices (phones, 600px and down) */
#media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
#media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
#media only screen and (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
#media only screen and (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
#media only screen and (min-width: 1200px) {...}
Another approach is to handle icon sizes on their wrappers. You can set the icon size to auto and change their parent size. You can do it on media queries or with any other method.
<IconContext.Provider value={{ size: 'auto' }}>
<App />
</IconContext.Provider>

Angular 2 web app using fluid layout not responding to more than one screen sizes

Here, I am creating a new web application using Angular 2 framework and applying media query for responsiveness. I am new to this design. I had used two screen breakpoints i.e 600 and 960 and trying to test the responsiveness accordingly. But one of my query not getting apply i.e. 600px.
This is my code,
#media screen and (max-width: 600px) {
mat-card{
width:50%;
height:60%;
margin:9% 9% 9% 19%;
font-size:8px;
}
.fullwidth{
width:50%;
height:50%;
font-size:11px;
padding:10px;
}
mat-card-title{
font-size:13px;
font-weight:bold;
}
mat-card-subtitle{
font-size:11px;
}
}
#media screen and (max-width: 960px) {
mat-card{
width:50%;
height:60%;
margin:9% 9% 9% 19%;
font-size:8px;
}
.fullwidth{
width:90%;
height:50%;
font-size:11px;
padding:10px;
}
mat-card-title{
font-size:13px;
font-weight:bold;
}
mat-card-subtitle{
font-size:11px;
}
}
But in actual browser only media query for 960 is getting applied on 'fullwidth' class.
How can I apply media query to 600px size?
Also how many screen sizes needs to be queried for proper responsive design?
see if this helps you: https://codepen.io/panchroma/pen/pLaJZy
Remember that all CSS rules that are applicable will be applied to an element, and CSS rules cascade. With your original CSS, if the viewport was say 500px, your two media queries would be true, so the last one would be the styling that would be applied.
Instead of your original
#media screen and (max-width: 600px) {
...
}
#media screen and (max-width: 960px) {
...
}
Consider something like the following
#media screen and (max-width: 600px) {
...
}
#media screen and (min-width:601px) and (max-width: 960px) {
...
}
With the above CSS, if the viewport is 500px the first media query will apply, if the viewport is 700px the second media query will apply.
Hope this helps!

Bootstrap 3 Media Queries working on Chrome but not on Mobile devices

Ok the question has been asked many time before and I went through each and everyone of them but it didn't worked for me
In mobile view I want to set slideshow col position from Relative to Static which will result into this
But instead I'm seeing this on mobile (adjacent col is overlapping)
which means Col is still in relative position and media Queries are not working on mobile platforms however It does work in Desktop Chrome browser.
I used meta tags and different combinations of min and max values (after confirming screen resolution)
for example
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-width : 320px)
and (max-width : 480px) {
section.banner .slideshow-col{
position: static;
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 320px) {
section.banner .slideshow-col{
position: static;
}
#media (min-width : 700px) {
section.banner .slideshow-col{
position: static;
}
#media (min-width: 992px) {
section.banner .slideshow-col{
position: relative;
}}
#media (min-width: 1200px) {
section.banner .slideshow-col{
position: relative;
}}
My website is here http://
Any hint?
Try to use this solutions
#media screen and (max-width: 760px){
.slideshow-col {
position: relative;
height: 300px; <-- height of the slideshow
// You can use min & max height of slideshow for mobile devices
height: auto;
min-height: xxx;
max-height: xxx;
}
}

Media Query for screens above 1920x1080 to 2560x1600 including retina displays

I have used media queries for other resolutions which is as follows: #media (max-width: 767px) and (min-width: 0px) {...} #media (max-width: 1366px) and (min-width: 768px) {...} #media (max-width: 1024px) and (min-width: 768px) {...}
Since the client wants specific look on these resolutions. But now on higher resolutions the website is distorting and i need the right query which says "Any screen resolutions above 1920x1080 including retina display should have this look". Else i feel i will have to write queries for specific famous resolutions above 1920x1080.
//(1920x1080) Full HD Display
#media (min-width: 1920px) and (max-width: 2560px) {
//insert styles here...
}

Resources