Mobile/Desktop media query not working on cell phone - html

Last night I worked on making my site mobile optimized. When a user is on a device with less than 684px it should show the mobile nav div and hide the sidebar div. I have tested this as working on my computer (by shrinking chrome like an accordion). I also checked https://www.google.com/webmasters/tools/mobile-friendly/?url=www.kisnardonline.com to see my status, but it says my site is not mobile friendly(I realize my links together is likely valid/viewport too). I will make the links more spread once I get it working overall. Thanks for any help!
Here is my code(http://www.kisnardonline.com/wp-content/themes/mytheme/style.css):
#wrapper {
display: block;
min-width: 684px;
max-width: 1200px;
width: 98%;
margin: 0px auto; }
#media screen and (max-width: 684px) {
#wrapper {
min-width: 0px; /* show under 684px - mobile */
}
}
#content {
width: 74%;
float: right; }
#media screen and (max-width: 684px) {
#content {
width: 100%; /* show under 684px - mobile */
}
}
#mobilenav {
display: none;
margin: 15px auto;
padding: 10px 10px 10px 10px;
border-radius:20px;
border:3px solid #a1a1a1;
background:#1C2939; }
#media screen and (max-width: 684px) {
#mobilenav {
display: block; /* show under 684px - mobile */
}
}
#sidebar {
display: block;
width: 23%;
min-width: 170px;
max-width: 210px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
float: left; }
#media screen and (max-width: 684px) {
#sidebar {
display: none; } /* hide under 684px - mobile */
}
Here is my desktop (greater than 684px view):
Here is my desktop (less than 684px view):
Here is my mobile view(Samsung Galaxy S6):

For responsive pages you need to add a viewport tag which tells the device how to display the content:
<meta name="viewport" content="width=device-width, initial-scale=1">
For your other question, the "request desktop site" won't work the way you have it set up. That feature is for if you have 2 separate sites(one for mobile and one for desktop). For instance the mobile site would be m.kisnardonline.com and would have different files than the desktop site.

Related

Declaring CSS properties to display images across multiple screen sizes

I am using media queries to adjust the size of images according to the screen size they will be displayed at. I am creating 5 breakpoints.
Here is a link to what I have created so far, and here is a link to the repository of the files for the project.
I'm using Google Chrome DevTools to check how the project looks.
Everything runs well on desktop, iPad Pro, and all phone screens as you can see here:
iPad Pro display
Pixel 2 display
But one of the iPad options does not get rendered properly when I use media queries. Here is the anomaly: the image is not sized property and gets stretched.
iPad display
If I fix the iPad, the media query for iPad Pro becomes unresponsive and gets automatically displayed too wide. If I fix the iPad Pro, then the iPad one becomes unresponsive and gets displayed too wide or not at all.
I am using Visual Studio Code and there I have created three CSS files: index.html along with main.css, main1.css and main2.css.
To do that with the image, this is my html code:
<img class="img" src="logo1.png"
alt="My business' website logo"/>
<img class="imagerkan" id="imagery" src="logo1.png"
alt="My business' website logo"/>
This is my CSS at main.css:
#media screen and (min-width: 85.375rem) {
.img {
display: block;
margin-top: 7%;
margin-left: auto;
margin-right: auto;
height: 29.875rem;
width: 31%;
border-radius: 1.25rem;
}
#imagery {
display: none;
}
.imagerkan {
display: none;
}
}
#media screen and (max-width: 64rem) {
.img {
display: block;
margin-top: 21%;
margin-left: 17%;
margin-right: auto;
height: 11.875rem;
width: 68%;
border-radius: 1.25rem;
}
#imagery {
display: none;
}
.imagerkan {
display: none;
}
}
However, when I get to this next part, everything crumbles for one of the iPads:
main1.css:
#media only screen and (min-width: 64rem) and (max-width: 85.375rem) {
#imagery {
display: block;
margin-top: 14%;
margin-left: auto;
margin-right: auto;
height: 29.875rem;
width: 61%;
border-radius: 1.25rem;
}
.img {
display: none;
}
.imagerkan {
display: none;
}
}
This produces my intended outcome on iPad Pro.
But when I want to use another media query so my image displays correctly on iPad, the 768 x 1024 size, nothing I do works. I get the distorted image posted earlier.
The only reason I created an additional css file was because I was having the same problem with the iPad Pro version when I was including the media query for it in main.css. But when I created main1.css and placed my media query there for iPad Pro there, it worked.
At first I had the media query for iPad the 768 x 1024 size, in main1.css,
but thinking that just like having created main1.css for the iPad Pro
media query fixed the problem for it, I made main2.css for the iPad
media query. This time it did not work.
Here's main2.css.
#media only screen and (min-width: 51.5rem) and (max-width: 64rem) {
(824PX , the largest of the 7 phone sizes) (1024PX)
.imagerkan {
display: block;
margin-top: 14%;
margin-left: auto;
margin-right: auto;
height: 29.875rem;
width: 5%;
border-radius: 1.25rem;
}
.img {
display: none;
}
#imagery {
display: none;
}
}
I tried changing the media query for all phones in main.css to max 51.5 rem but this did not fix the problem either. One of the iPad media queries becomes unresponsive.

Web page moves horizonatally in the Iphone 7

I see that the website home page horizontally moves when a user scrolls the page.
Below is the URL:
https://tandcity.dk/da/
I have tried the below CSS
body{
overflow: hidden;
}
html{
overflow: hidden;
}
I added some meta tags. You can check on view source.
Can someone please help me to fix this.
Remove this from body tag:
body {
/* overflow: hidden; */
/* width: 100vw; */
/* height: 100vh; */
}
For Mobile:
On this class .vc_grid.vc_row.vc_grid-gutter-15px .vc_pageable-slide-wrapper remove margin-right: -15px replace with margin-right: 0px if you want to.
Afrter that replace .vc_grid.vc_row.vc_grid-gutter-15px .vc_grid-item , padding-right: 15px; with padding-right: 0px;
Remember for this mobile chages to take affect you have to add it within an #media query.
Example: Where you add the custom css, add this before the closing tag
#media (max-width: 480px) {
.vc_grid.vc_row.vc_grid-gutter-15px .vc_pageable-slide-wrapper {
margin-right: 0px;
}
.vc_grid.vc_row.vc_grid-gutter-15px .vc_grid-item {
padding-right: 0px;
}
}
For iphone 7 :
/* Portrait and Landscape */
#media only screen
and (min-device-width: 414px)
and (max-device-width: 736px)
and (-webkit-min-device-pixel-ratio: 3) {
.vc_grid.vc_row.vc_grid-gutter-15px .vc_pageable-slide-wrapper {
margin-right: 0px;
}
.vc_grid.vc_row.vc_grid-gutter-15px .vc_grid-item {
padding-right: 0px;
}
}

Use Mobile menu (burger) on mobile and tablet sizes for a foundation 5 site

I'm sure this has been asked but I can't seem to find an example that isn't using SASS. I just have a regular CSS file that I'm working with. I want the burger menu to change to the horizontal menu on the larger size.(#media only screen and (min-width: 64.063em)) I've seen a few posts saying to update the settings.scss file like this(http://foundation.zurb.com/forum/posts/1483-customize-topbar-breakpoint-in-scss) but again I'm not using SASS for this project. I just can't seem to figure out what is triggering the menu to change from mobile to desktop: media queries or javascript.
If you want to use CSS you can override the Foundation CSS in a separate CSS file (ie:styles.css) section that follows the foundation.css
Demo on Codeply
#media only screen and (max-width: 64.063em) {
.top-bar {
overflow: hidden;
height: 2.8125rem;
line-height: 2.8125rem;
position: relative;
background: #333;
margin-bottom: 0;
}
.top-bar-section {
left: 0;
position: relative;
width: auto;
transition: left 300ms ease-out;
}
.top-bar-section ul {
padding: 0;
width: 100%;
height: auto;
display: block;
font-size: 16px;
margin: 0;
}
.top-bar .toggle-topbar.menu-icon {
top: 50%;
margin-top: -16px;
display:block;
}
.top-bar .title-area {
float: none;
}
}
http://codeply.com/go/OtVVMn0n6V
If you don't want to use SASS, then you'd better change foundation.css file.
Around line 1682 change it from
meta.foundation-mq-topbar {
font-family: "/only screen and (min-width:40.063em)/";
width: 40.063em;
}
to
meta.foundation-mq-topbar {
font-family: "/only screen and (min-width:64.063em)/";
width: 64.063em;
}
Also around line 2006, change it from
#media only screen and (min-width: 40.063em) {
To
#media only screen and (min-width: 64.063em) {

Iphone responsive website issue

I am creating a new website, here is the www.qldmetals.com
Everything seems to be fine on website except its responsiveness on iPhone. In iPhone the logo sits over the navigation menu. I tried the following media query, but it doesn't seems to be working for me i.e
#media only screen
and (min-device-width : 320px)
and (max-device-width : 568px) { .logo a.brand { display: block !important; }}
I'm confuse, Is this error because of display method or anything else (like I have to use media query for any other class)
I appreciate your help and your valuable time.
Thank you.
I have seen your website and after that i have created some of my own style element which i am sharing it's only for media screen max width 480px
Following Code
#media (max-width:480px){
.logo a.brand {
display: block !important;
height: auto;
line-height: 30px;
margin: 0;
overflow: hidden;
padding: 0;
width: auto;
}
.logo a.brand img {
float: none;
height: auto;
margin: 2px 8px 2px 0;
width: 100%;
}
header .logo{
float: none;
max-height: none;
text-align: center;
width: 100%;
}
}

Menu problems and display sizes

I have a vertical menu on my website which I want to make horizontal when I shrink the webpage, how can I achieve this?
I leave here the site:
Link
I am using WordPress to create this website if that helps
the only thing the menu has so far is this:
#menu_esquerda{
float: left;
}
#menu-o-menu{
list-style: none;
margin-top: 20px;
}
#menu-o-menu a{
color: white;
text-decoration: none;
font-family: Lato, Arial;
}
#menu-o-menu li{
padding-bottom: 10px;
}
Use media queries to target the css to specific devices.
In your case assuming that you want to make the menus horizontal when you resize the window and the window size is less that 980px, declare the styles to be applied for all the devices with width below 980px within the below declaration
#media screen and (max-width: 980px) {
// write the css here
}
To make the menu horizontal try this
#media screen and (max-width: 980px) {
#lateral{
float:none;
width:100%;
}
#desc_fantas p{
height:auto; // you have declared 100px height for this initially, i just changed it to reduce the height when the menu is horizontal. Change it as you need.
}
#menu-o-menu{
text-align:center;
}
#menu-o-menu li{
display:inline-block;
}
}
Use conditionals. At a certain width, the CSS would change and convert the menu into a horizontal one. Something like this. THIS code is no way related to your website. That is up to you to do!
#media screen and (min-width: 600px) {
#header ul {
display: block;
margin-right: 1.02048%; /* 10/980 */
}
#header form {
display: none;
}
#footer p {
display: block;
line-height: 30px;
color: #4e4e4e;
text-align: left;
float: left;
width: 16.3265%; /* 160/980 */
min-width: 120px;
margin-left: 1.0204%; /* 10/980 */
}
}
#media screen and (min-width: 1000px) {
#header form {
display: block;
}
#header ul a {
display: block;
float: left;
width: 74px;
}
#header div > a.mobile {
display: none;
}
}
you used max-width and max-height.
In such a situation, instead of width and max-width to the browser in a small window, you can improve the way it handles.
You've got a div#lateral on there that has a width="300px" that is confining your whole sidebar area. So, you've only got that much room to work with horizontally.
setting the display="inline-block" on your li elems works, but you'll need to dramatically adjust your font-size and margins, etc to make it look nice.