I'm trying to hide and show a column when it's on desktop or on mobile.
I've been trying for few hours to make it work but to no avail. As you can see in the images attached, the one circled in red is what I'm trying to hide.
I tried to put in extra class named hide_mobile for the one I but it didn't work:
#media only screen and (max-width: 674px) {
.hide_mobile{
display:none !important;
}
}
Mobile
Desktop
Any help would be greatly appreciated.
Thanks.
if you are using wordpress you can do a stylesheet only for mobile.
For example mobile.css and with a php code in the header, you can call it only when you are using a mobile phone.This is an example for mobile and ipad:
<link rel="stylesheet" media="screen and (min-width: 80px) and (max-width: 700px)" href="/wp-content/themes/theme-child/iphone.css">
<link rel='stylesheet' media='screen and (min-width: 701px) and (max-width: 900px)' href='/wp-content/themes/theme-child/ipad.css'>
With me it works great.
Related
I'm working on a web app using version 4 of Angular.
I want to show a different style for smaller devices and large screen devices. For example, when a user is browsing on mobile size device, the page will be very long which is not good in UX point, but it would be better if I could convert that long page to tabs that user can swipe between them (like menus). Is there any known way by bootstrap or any technique in Angular 4 to helps me for that?
You can use media query and either create a separate file for each:
//index.html
<link rel="stylesheet" media="(max-width: 360px)" href="mobile.css" />
<link rel="stylesheet" media="(min-width: 361px) and (max-width: 1080px)" href="tablet.css" />
<link rel="stylesheet" media="(min-width: 1081px)" href="desktop.css" />
or create everything in one file:
//style.css
#media (max-width: 360px) {
//Mobile
}
#media (min-width: 361px) and (max-width: 1080px) {
//Tablet
}
#media (min-width: 1081px) {
//Desktop
}
See also: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
I have searched and searched and I can not seem to find a reason why my html meta tag is not working on my iPhone. You can visit my website at http://hadenhiles.mooo.com. If you resize the viewport (window) you will see that my site responds totally as expected... however when you view it on a mobile device you get a result that looks as though it is a desktop version. here is the head tag and it's contents:
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="bootstrap/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
As you likely have noticed I use my own stylesheet as well as the bootstrap3 stylesheet. I know I should likely stick to one or the other when it comes to layout but I made this website using only my own media queries before I was introduced to bootstrap. I only use bootstrap in the footer and for popups/navbar features. Anyway bootstrap is not the issue. It seems as though the meta tag is not recognizing the device width and is not setting the initial scale to 1.0. I have tried varying the min-width of my queries to debug but had no success. Here is are my css media queries:
/* Main css */
#media only screen and (min-width: 1px) and (max-width: 320px){
/* content */
}
#media only screen and (min-width: 321px) and (max-width: 600px){
/* content */
}
#media only screen and (min-width: 601px) and (max-width: 768px){
/* content */
}
#media only screen and (min-width: 769px) and (max-width: 1020px){
/* content */
}
I have tried switching from #media only screen and to #media screen as someone suggested in another question but had no success either. At first I thought that the min/max width was too big/small for mobile devices so I changed that and nothing happened. I have had this problem for about 3 months now so I decided to publish my own question. Any help you can give me is much appreciated.
~Haden
So this isn't exactly defining what's going on, although I do think that it is due to min and max conflicts. Try setting only max-width since that seems to be covering everything. It seems redundant to say min-width is 1px and max width is 320px and then for the next media query to be 321px. If you set the max-width to 320px, it will cover that range. If you set the next one to 600 pixels, it will cover the 320-600 range, etc.
#media only screen and (max-width: 320px){
/* content */
}
#media only screen and (max-width: 600px){
/* content */
}
#media only screen and (max-width: 768px){
/* content */
}
#media only screen and (max-width: 1020px){
/* content */
}
Alternatively, you might try using min-device-width and max-device-width. Here's a link to a decent resource on media queries for standard devices.
This question already has answers here:
Why are my CSS3 media queries not working on mobile devices?
(23 answers)
Closed 9 years ago.
I keep trying to do a media query in my CSS doc doing something like:
#media screen and (max-device-width: 480px) { /*css here*/}
but it won't work when I test it on an iPhone. I've tried changing the sizes and using the portrait/landscape feature, but still nothing. What am I doing wrong?
Check that you have
<meta name="viewport" content="width=device-width, initial-scale=1.0">
in the head of your doc
I always call mine when I link the CSS in the head of the HTML.
An example from a current page I'm working on:
<link rel="stylesheet" type="text/css" media="screen and (min-device-width: 320px) and (max-device-width: 500px)" href="css/mobile.css" />
<link rel="stylesheet" type="text/css" media="screen and (min-device-width: 501px)" href="css/main.css" />
This selects the CSS doc that will be loaded right from the start instead of selecting styles after the CSS document is loaded (reduces number of HTTP requests)
When doing this within the CSS document itself, you should generally replace max-device-width with max-width.
this is a samples media query css
/************************************************************************************
smaller than 980
*************************************************************************************/
#media screen and (max-width: 980px) {
your css here
}
/************************************************************************************
smaller than 650
*************************************************************************************/
#media screen and (max-width: 650px) {
your css here
}
/************************************************************************************
smaller than 560
*************************************************************************************/
#media screen and (max-width: 480px) {
your css here
}
Hard to understand as you have not provided the code..but the common mistake people do it by not adding this meta data
<meta name="viewport" content="width=device-width, initial-scale=1">
Use "max-width" instead of "max-device-width" which is fixed per device.
I'm not sure but I think the max-device-width of an iphone is 640px. Give it a try.
#media only screen and (min-width : 480px) {
}
It seems to work fine in both Android and iPhone.
I need to float a div to the left when on the portrait mode via iPad. No matter what code that's inserted, nothing changes. Here's what I'm doing:
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
.logos{
float: left;
}
}
The site I'm working on: http://rachelsilberman.com/rob-anolik/
The "logos" div pushes down when someone is on the iPad, and I need it to float left so it will align with the contact div.
I've been using ipadpeek.com to view the outcome since I don't have one myself. Hopefully that doesn't make a difference.
Thanks!
You should be adding the attribute to your ipad css like below:
#media only screen and (min-device-width: 768px)
and (max-device-width: 1024px) and (orientation:portrait) {
.logos{
float: left;
}
}
GENERAL RULE FOR CSS FOR IPAD IS LIKE BELOW:
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
I figured it out tonight. This may help others. I had to comment out the following line in my library.php file:
<!--<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/tablet.css" type="text/css" media="screen and (min-width:640px) and (max-width:1023px)" />!-->
After this, everything referred to the main style.css sheet which I wanted. I included two statements:
#media only screen and (min-width:641px) and (max-width:1023px) and (orientation:portrait) {
and
#media (max-device-width: 600px) and (orientation: portrait) {
Due to the issues I was observing on a Blackberry Playbook versus an iPad, I had to introduce the second #media line. I simply tweaked the values within those sections of my style.css code and voila! Everything works finally.
Here's a great site on the different sizes for screens: http://nmsdvid.com/snippets/
I checked my blog on tablets and netbooks and it looked a bit bad, so I made an extra css and added to header.php in between :
<head>
<link media="all and (min-width: 481px) and (max-width: 768px)" type="text/css" rel="stylesheet" href="tablet.css">
</head>
But nothing happens. How to add an extra .css to make this work ?
Also tried to add this function to themes functions.php, but blog crashes.
wp_enqueue_style('my-custom-style', 'get_bloginfo('template_url') . '/css/tablet.css',false,'1.1','all and (min-width: 481px) and (max-width: 768px)');
What should I add in 'template_url' and what is the simpliest way of achieving my goal?
Thanks!
Try this :
<link rel="stylesheet" type="text/css" href="path/to/your/css/file.css">
Add it to you template header.php file, after <?php wp_head(); ?> and after your last stylesheet.
If this fails add it just before the </head> tag.
Also make sur your the path to your stylesheet is correct, if your not sure use the full path:
<link rel="stylesheet" type="text/css" href="http://www.site.com/path/file.css">
Hope it helps
You just add the code below into the bottom of your stylesheet and apply the styles that you want for those specifications in there. That's for an exact size though.
#media all and (max-width: 768px) and (min-width: 481px) {
Your styles go in here
}
The code below this will target a max-width of 768px or a min-width of 481px.
#media all and (max-width: 768px), (min-width: 481px) {
Your styles go in here
}