Issue with #media rule - html

So I was at work making a page and i put my #media rules in a responsive.css file. So it worked all fine, until i uploaded to server and the responsive.css is still being called but none of its rules are working. i also found this to be the case at home as well. Any ideas why this might be?
below is my links i used.
and the responsive.css file.
again this works at work but not anywhere else, the styles .css works fine so does my jquery scripts.
Thanks in advance
(unable to show full code for CopyR reasons)
mobilenav {
display: none;
font-size: 450%;
position: fixed;
right: 0;
top: 0;
height: 1em;
z-index: 10;
justify-content: center;
align-items: center;
align-content: center;
width: 20%;
background-color: var(--katlgreen);
}
mobilenav h1 {
background-color: transparent;
}
navmenu {
position: fixed;
top: 0;
width: 100%;
height: 100%;
display: flex;
flex-flow: column;
background-color: var(--katdgreen);
z-index: 9;
}
navmenu a {
margin-left: 2em;
font-size: 150%;
margin-top: 3em;
font-weight: 900;
}
/* columns and removes */
#media only screen and (max-width: 1200px) {
td {
font-size: 90%;
}
}
#media only screen and (max-width: 950px) {
column {
width: 48%;
margin-top: 1em;
}
}
#media only screen and (max-width: 450px) {
column {
width: 98%;
margin-top: 1em;
}
#estlogo {
display: none;
}
brandbuttons {
display: none;
}
nav {
display: none;
}
tab {
display: none;
}
header {
background-color: var(--katlgreen);
margin-bottom: 1em;
height: 5em;
align-content: center;
}
mobilenav {
display: flex;
}
#katlogo {
margin: auto 5%;
}
}
/* columns and removes */
#media only screen and (min-width: 951px) and (max-width: 1200px) {
nav {
width: 50%;
}
tabline {
width: 55%;
}
}
#media only screen and (min-width: 750px) and (max-width: 950px) {
.brandbutton2 {
width: 40%;
margin: 0;
}
.brandbuttons2 {
justify-content: space-around;
width: 100%;
}
#katlogo {
width: 120px;
}
#estlogo {
width: 80px;
}
nav {
width: 50%;
}
tabline {
width: 55%;
}
}
#media only screen and (min-width: 360px) and (max-width: 749px) {
* {
font-size: 98%;
}
.brandbutton2 {
width: 40%;
margin: 0;
}
.brandbuttons2 {
justify-content: space-around;
width: 100%;
}
nav {
width: 80%;
}
tabline {
width: 85%;
}
#katlogo {
width: 120px;
}
#estlogo {
width: 80px;
}
}
#media only screen and (min-width: 250px) and (max-width: 359px) {
* {
font-size: 98%;
}
#katlogo {
width: 100px;
}
}
#media only screen and (max-width: 250px) {
* {
font-size: 96%;
}
#katlogo {
width: 80px;
}
}
/* mobile change hdr tab to menu complete
/* vs device delete second logo and remove 2 buttons. complete
<link href="styles.css" rel="stylesheet" type="text/css">
<link href="functions.css" rel="stylesheet" type="text/css">
<link href="responsive.css" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">

perhaps use min-width instead of max-width

Best method i found to fix this soulution is adding the following meta code for mobile responsiveness.
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Related

How to set a css property depending on desktop or mobile view?

I would like to have 2 different margin for the same div depend on mobile and desktop view.
The code below can perform a margin-left: 70px; on desktop.
The problem arises on mobile view, it doesn't reset to margin-left: 0px;
How can I do it ?
Thanks.
.body-container {
padding-left: 0px;
padding-right: 0px;
max-width:1350px;
}
.content {
margin-left: 70px;
}
.content-collapsed {
margin-left: 0px;
}
You're not resetting margin in .content
You need to use media queries
The solution below uses non-mobile approach
body {
margin: 0;
}
.content {
background: red;
margin-left: 70px;
}
#media (max-width: 800px) { /*choose the width you prefer*/
.content {
margin-left: 0;
}
}
<div class="content">content</div>
The solution below uses mobile approach (recommended, also is the same used by bootstrap 4)
body {
margin: 0;
}
.content {
background: red;
margin-left: 0;
}
#media (min-width: 800px) { /*choose the width you prefer*/
.content {
margin-left: 70px;
}
}
<div class="content">content</div>
You can use media queries (MDN).
Example :
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
border: 1px solid black;
margin-left: 0px; /* mobile*/
}
/* screen width higher than 750px */
#media screen and (min-width: 750px) {
div {
margin-left: 70px;
}
}
<div></div>
Use media query. Add:
/* For mobile*/
#media only screen and (max-width: 768px) {
div {
margin-left: 0;
}
}
This is the solution that worked the best for my case:
<style>
.body-container {
padding-left: 0px;
padding-right: 0px;
max-width:1350px;
}
.content {
margin-left: 70px;
}
##media (max-width: 800px) { /*choose the width you prefer*/
.content {
margin-left: 0px;
min-width: 100%;
}
}
</style>
Thank you. You made my day.

responsive drop down menu not drop down in media screen

The responsive drop down menu work well here:
https://klia2.co/include/header.htm
but when insert to content page as below, the drop down menu not drop down when view in media screen.
https://klia2.co/index2.htm
compared the 2 links to understand the actual scenario.
Notice that the alignment of logo header and menu in content page also not tally.
Kindly assist to rectify the issue and all suggestion are most welcome and appreciated.
HTML PAGE - index2.htm
<body>
<div id="header"></div>
<div class="content">
<br>
<br>
** content **
<br>
<br>
<div id="footer"></div>
</div>
</body>
HTML PAGE - header.htm
<body>
<div class="content">
<header id="logo"></header>
<div class="navbar" id="nav">
Home
Facilities
Airlines Offices
<form class="search-box">
<input type="text" placeholder="Search..">
<button type="submit" class="search-icon"><i class="fa fa-search"></i></button>
</form>
<i class="fa fa-bars"></i>
</div>
</div>
<script>
function myFunction() {
var x = document.getElementById("nav");
console.log(barIcon)
if (x.className === "navbar") {
x.className += " responsive";
var barIcon = document.getElementsByClassName('fa-bars')[0];
barIcon.classList.add("fa-times");
barIcon.classList.remove("fa-bars");
} else {
var closeIcon = document.getElementsByClassName('fa-times')[0];
closeIcon.classList.remove("fa-times");
closeIcon.classList.add("fa-bars");
x.className = "navbar";
}
}
</script>
</body>
CSS CODE - style1.css
/* CSS Reset */
body {font-family:Arial;
}
.content {
max-width: 1040px;
margin: auto;
}
/*--------------------------logo---------------------------------*/
#logo {
background: transparent url("images/airlineshq-logo.jpg") no-repeat scroll 0% 0%;
width: 1040px;
height: 150px;
border: 0;
margin-bottom: 0;
}
#media only screen and (max-width: 600px) {
#logo {
width: 100%;
}
}
/*--------------------------menu---------------------------------*/
.navbar {
overflow: hidden;
background-color: #0000ff;
}
.navbar a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 14px;
text-decoration: none;
font-size: 17px;
height:18px;
}
.active {
background-color: #0033CC;
color: white;
}
.navbar .icon {
display: none;
}
.navbar a:hover, input:hover {
background-color: #dddddd;
color: black;
}
/* CSS for search box */
.navbar .search-box {
float: right;
position: relative;
margin-top: 3px;
padding-right: 30px;
display: flex;
}
.navbar .search-box input {
padding: 12px;
border: none;
width: 100%;
height: 100%;
padding: 10px;
}
.navbar .search-box button {
color: #999;
border: navajowhite;
padding: 10px;
}
#media screen and (max-width: 600px) {
.navbar a, .navbar .search-box, .navbar .search-icon {
display: none;
}
.navbar a.icon {
float: left;
display: block;
}
}
#media screen and (max-width: 600px) {
.navbar.responsive {position:relative;}
.navbar.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.navbar.responsive a {
float: none;
display: block;
text-align: left;
}
.navbar.responsive .search-box {
float: none;
display: flex;
width: 90%;
padding: 4%;
border: 2px solid black;
}
.navbar.responsive .search-icon{
display: flex;
}
}
/*--------------------------body------------------------*/
/* Column container */
.row {
display: -ms-flexbox; /* IE10 */
display: flex;
-ms-flex-wrap: wrap; /* IE10 */
flex-wrap: wrap;
}
/* Create two unequal columns that sits next to each other */
/* Sidebar/left column */
.side {
-ms-flex: 30%; /* IE10 */
flex: 30%;
background-color: #f1f1f1;
padding: 20px;
}
/* Main column */
.main {
-ms-flex: 70%; /* IE10 */
flex: 70%;
background-color: white;
padding: 20px;
}
/* Fake image, just for this example */
.fakeimg {
background-color: #aaa;
width: 100%;
padding: 20px;
}
/* Footer */
.footer {
padding: 20px;
text-align: center;
background: #ddd;
}
/* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 700px) {
.row {
flex-direction: column-reverse;
}
}
/* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other
#media screen and (max-width: 400px) {
.navbar a {
float: none;
width: 100%;
}
}*/
Footer is the issue. Remove css, which breaks navbar styles. Also meta tags should be in the header. Screenshot https://prnt.sc/1t7vjgu

How I can create div only for mobile version?

I want to create div in html with images and texx, but It should appears only on mobile version, how i can make this ?
Here is some code.
/*-- Mobile Design---- */
#media (min-width: 320px) and (max-width: 767px) {
/* put your css styles in here */
html,
body {
margin-top: 0;
margin-bottom: 0;
}
a.navbar-brand img {
padding: 0;
display: flex;
margin-left: 10px;
margin-right: auto;
width: 95%;
max-width: 200px;
}
.header {
height: 15%;
}
.navbar-toggler i {
font-size: 22px;
margin-right: 10px;
}
Hide the element by default and only show it when it fits your contraints. For example:
.yourElement {
display: none;
}
#media (min-width: 320px) and (max-width: 767px) {
.yourElement {
display: block;
}
}

Media Queries not working even with <meta> tag

I have a simple website that I am making for my music over at (secure tunnel) http://79a6b00f.ngrok.io using media queries and everything, with the meta tag (<meta name="viewport" content="width=device-width, initial-scale=1">)in the header on index.html.
I have had someone test it on their phone, and the website zooms out, instead of maintaining scale and showing a hamburger menu. Here's my query code:
#media all and (max-width: 2600px) {
.w-ctrl {
width: 950px;
margin: auto;
}
}
#media all and (max-width: 966px) {
.w-ctrl {
width: 100%;
margin: auto;
}
.sub-header {
width: 100%;
background: #37474F;
height: 500px
}
.lnd-con .pic {
height: 500px;
background-attachment: scroll;
}
.lnd-con .label-con {
top: -350px;
text-align: center;
}
.label-con .title {
font-size: 25px;
}
.label-con .subtitle {
font-size: 25px;
}
}
#media all and (max-width: 636px) {
.w-ctrl {
width: 100%;
margin: auto;
}
.nav-con-big {
display: none;
}
.nav-con-small {
display: block;
}
.lnd-con .pic {
height: 300px;
}
.title-con {
display: none;
}
.lnd-con {
margin-top: 0px;
}
.lnd-con .label-con {
position: static;
text-align: left;
background: transparent;
padding-top: 5px;
padding-bottom: 8px;
letter-spacing: 0px;
}
.label-con .title {
font-size: 20px;
}
.label-con .subtitle {
font-size: 18px;
}
.sub-header {
width: 100%;
height: 400px
}
}
I could not fit my website into a js-fiddle, so I created a tunnel instead. I hope it's okay, as far as I am aware I'm not breaking any rules.
I see this declaration at the top of your global.css:
#viewport {
zoom: 1.0;
width: extend-to-zoom;
}
take it out or set width: device-width;:
#viewport {
width: device-width;
}
also, support for css device adaptation is pretty poor (http://caniuse.com/#search=%40viewport), possibly it is somehow conflicting with the meta tag implementation
You have to show us what meta viewport tag your using for #1. There are many.
But also; if you'd like to see the changes within your browser you can always write the media queries as between 2 widths as below:
/* SAMPLE No greater than 900px, no less than 400px */
#media (max-width:900px) and (min-width:400px) {
.CurrentlyOnVacation {
display:none;
}
}​

Having issues with my website not being responsive

I am having an issue with my website not being responsive even though I already created the code to make it so. The images on my site don't get rearranged when I change the size of the browser.
The website is whoissaveliy.com
Below is my responsive.css file which contains the code that I created to make my site responsive. As well as my index.html file code. Please let me know what else you may need to see or know in order to help me with the issue.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Saveliy Yusufov | Working Professional</title>
<link rel="stylesheet" href="css/normalize.css">
<link href='http://fonts.googleapis.com/css? family=Changa+One|Open+Sans:400italic,700italic,400,700,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/responsive.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
responsive.css
#media screen and (min-width: 480px) {
/**********************************
TWO COLUMN LAYOUT
***********************************/
#primary {
width: 50%;
float: left;
}
#secondary {
width: 40%;
float: right;
}
/**********************************
PAGE: PORTFOLIO
***********************************/
#gallery li:nth-child(3+1) {
clear: left;
}
#gallery li {
background-color: orange;
width: 28.3333%;
}
}
/**********************************
ABOUT
***********************************/
.profile-photo {
float: left;
margin: 0 5% 80px 0;
}
#media screen and (min-width: 660px) {
/**********************************
HEADER
***********************************/
nav {
background: none;
float: right;
font-size: 1.125em;
margin-right: right;
width: 45%;
}
#logo {
float: left;
margin-left: 5%;
text-align: left;
width: 45%;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 0.25em;
margin-bottom: 20px;
}
header {
border-bottom: 5px solid #599868;
margin-bottom: 60px;
}
}
#media screen and (min-width: 480px) {
/**********************************
TWO COLUMN LAYOUT
***********************************/
#primary {
width: 50%;
float: left;
}
#secondary {
width: 40%;
float: right;
}
/**********************************
PAGE: PORTFOLIO
***********************************/
#gallery li:nth-child(3+1) {
clear: left;
}
#gallery li {
background-color: orange;
width: 28.3333%;
}
}
/**********************************
ABOUT
***********************************/
.profile-photo {
float: left;
margin: 0 5% 80px 0;
}
#media screen and (min-width: 660px) {
/**********************************
HEADER
***********************************/
nav {
background: none;
float: right;
font-size: 1.125em;
margin-right: right;
width: 45%;
}
#logo {
float: left;
margin-left: 5%;
text-align: left;
width: 45%;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 0.25em;
margin-bottom: 20px;
}
header {
border-bottom: 5px solid #599868;
margin-bottom: 60px;
}
}
You need to add this media query in responsive.css itself. Use firefox and press (shift+ctrl+M) then select 480*320 and see your new styles are applying in that resolution. And also you need to add media query at the end of web page css