Hambuger Menu (Responsive) does not open on mobile safari (of iPhone 6) - menu

i tested the following responsive menu and it does not open with an iPhone 6 Safari:
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Hamburger-Menü Test</title>
<style>
*,::before,::after{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Verdana', sans-serif;
}
body {
margin: 0;
font-size:100%;
background: #f6f8f9;
}
nav {
display: flex;
height: 80px;
width: 100%;
background: #1c3464;
align-items: center;
padding: 0 50px 0 50px;
flex-wrap: wrap;
overflow: hidden;
position: fixed;
top: 0;
z-index:200000;
border-bottom: 4px solid #9acd32;
}
nav ul{
display: flex;
flex-wrap: wrap;
list-style: none;
position:absolute;
right:20px;
}
nav ul li{
margin: 0 5px;
}
nav ul li a{
color: #f2f2f2;
text-decoration: none;
font-size: 1.1em;
font-weight: 500;
padding: 8px 15px;
border-radius: 5px;
letter-spacing: 0.05em;
transition: all 0.3s ease;
}
nav ul li a.active{
color: #111;
background: #fff;
}
nav ul li a:hover {
background:#526788;
}
nav .menu-btn img{
color: #fff;
cursor: pointer;
display: none;
}
input[type="checkbox"]{
display: none;
}
#media (max-width: 1200px) {
nav{
padding: 0px 10px 0px 20px;
}
.menu-btn {
position:absolute;
right:20px;
}
nav .menu-btn img{
display: block;
}
#click:checked ~ .menu-btn i:before{
content: "\f00d";
}
nav ul{
position: fixed;
top: 80px;
left: -100%;
background: #173460;
height: 100vh;
width: 100%;
text-align: center;
display: block;
transition: all 0.3s ease;
z-index:200000;
}
#click:checked ~ ul{
left: 0;
}
nav ul li{
width: 100%;
margin: 40px 0;
}
nav ul li a{
width: 100%;
margin-left: -100%;
display: block;
font-size: 1.3em;
transition: 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
#click:checked ~ ul li a{
margin-left: 0px;
}
nav ul li a.active,
nav ul li a:hover{
background: none;
color: cyan;
}
}
</style>
</head>
<body>
<nav >
<input type="checkbox" id="click">
<label for="click" class="menu-btn">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAhCAIAAAAzse47AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAZUlEQVRIiWP8//8/A+0BEx3sGLVm1Bq6WcOCSyItM+fz58/EG2RuZlqQl0OyNXv27iPeDgYGBvzZHGegSUtJkWQNHx8fHlnG0cKGdDCa0rCC0ZRGdTCa0rCC0ZQ2as2oNaPW4AMAM3MvRji4G34AAAAASUVORK5CYII=">
</label>
<ul>
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
</ul>
</nav>
</body>
Hello world!
</body>
</html>
I tested also with a few my Samsung (Android) devices (Chrome)
Also with Windows (different browsers) and it works on all of them.
Any idea, what i can add so that safari will also work?
Please help ;-(
Best wishes
Daniel

Related

Flexbox text alignment on mobile

So, I am using flexbox for some columns. Basically column 1 is left-aligned, column two i centered, and column three is right-aligned. No big deal, or so I thought. In Chrome, everything looks fine, even when looking at things through Chrome's Inspect tool...but on my iPhone I can't get the right column to justify-content.
My code looks like:
<div id="nav">
<div class="wrap">
<div>
<p><i class="far fa-dot-circle"></i> Watch</p>
</div>
<div>
<p><img src="<?php bloginfo('template_directory'); ?>/images/logo.png" alt="" title="" /></p>
</div>
<div>
<p><i class="fas fa-donate"></i> Give</p>
</div>
</div>
</div>
The css looks like:
#nav div {
align-items: center;
display: flex;
flex: 1;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
letter-spacing: 2px;
line-height: 18px;
padding: 10px 20px 0;
text-transform: uppercase;
}
#nav > .wrap > div:nth-child(1) {
background: #00ff00;
justify-content: left;
}
#nav > .wrap > div:nth-child(2) {
background: #ff0000;
justify-content: center;
}
#nav > .wrap > div:nth-child(3) {
background: #0000ff;
justify-content: right;
}
#nav img {
max-width: 175px;
width: 100%;
}
#nav i {
color: #fff;
margin-right: 5px;
}
#nav a {
color: #fff;
text-decoration: none;
}
Here is the Fiddle: https://jsfiddle.net/1kw5g3h7/
I added the following code this morning and this works:
#nav > .wrap > div:nth-child(3) p {
text-align: right;
width: 100%;
}
I don't like this approach, it seems like to me the justify-content just isn't working is there a way to fix this using flexbox? I'm trying to understand why my original code isn't working on my iPhone? Maybe it's because I have Font Awesome icons in front of the text, I just don't know. Any ideas?
Thanks,
Josh
I didn't realize until now that I hadn't ever posted my final code. This is what I ended up with: https://jsfiddle.net/tc36e24s/2/
HTML:
<div id="head">
<div id="nav">
<i class="ion-android-close"></i>
<ul>
<li>Watch</li>
<li>Give</li>
<li><img src="images/logo.png" alt="Logo" title="Logo" /></li>
<li>Visitors</li>
<li>Contact</li>
</ul>
</div>
<div id="logo">
<p><img src="images/logo.png" alt="Logo" title="Logo" /></p>
<div onclick="openNav()" class="open">
<i class="ion-android-menu"></i>
</div>
</div>
</div>
CSS
body {
background: #009151;
}
#head {
display: flex;
flex-flow: column;
height: 100vh;
}
#nav ul {
flex: 0 1 auto;
}
#nav ul img {
max-width: 175px;
width: 100%;
}
#nav ul i {
color: #9ac2e7;
margin-right: 5px;
}
#nav li {
font-family: 'Open Sans', sans-serif;
letter-spacing: 2px;
line-height: 18px;
padding: 10px 20px 0;
text-align: center;
text-transform: uppercase;
}
#logo {
display: flex;
}
#logo img {
max-width: 200px;
margin: 20px 30px;
width: 100%;
}
#media screen and (max-width: 800px) {
#head .open {
color: #9ac2e7;
font-size: 30px;
margin: 20px 30px;
text-align: right;
width: 100%;
}
#head .open:hover {
cursor: pointer;
}
#nav {
background: #9ac2e7;
display: none;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1;
}
#nav ul {
align-items: center;
display: flex;
flex-flow: column;
height: 100%;
justify-content: center;
width: 100%;
}
#nav ul a {
color: #000;
text-decoration: none;
}
#nav li {
font-size: 20px;
padding: 10px 0;
}
#nav li:nth-child(3) {
display: none;
}
#nav .close {
color: #000;
font-size: 30px;
position: absolute;
right: 30px;
top: 20px;
}
}
#media screen and (min-width: 801px) {
#nav .close {
display: none;
}
#nav[style] {
display: block !important;
}
#nav ul {
align-items: center;
display: flex;
}
#nav ul a {
color: #9ac2e7;
text-decoration: none;
}
#nav li {
flex: 1;
font-size: 14px;
}
#logo {
display: none;
}
}
JS
function openNav() {
document.body.style.overflow="hidden";
document.getElementById("nav").style.display = "block";
}
function closeNav() {
document.body.style.overflow="scroll";
document.getElementById("nav").style.display = "none";
}
I added some JS to make my menu work on mobile, but other than that this is code I went with...which is pretty much the same as before except I added two additional links (one on each side of the logo).
Thanks,
Josh

My menu bar will not resize when window resizes

I'm having problems with my code. I have a fixed menu bar that works as it should but it doesn't resize when I change the size of the window. I need it to resize because if you change the window size, it will will not scroll horizontally and some buttons are cut off. How can I fix this?
Also feel free to make optimization or input on unnecessary code
Thanks
body {
margin: 0px;
padding: 0px;
background: url(images/gradient.jpg) no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: center;
}
section {
margin: 0 auto;
border: 1px solid #000000;
border-radius: 8px;
background:#E5E7E9;
width: 958px;
height: 800px;
}
.bpic {
width: 200px;
height: 350px;
margin: 0px;
}
.biopic {
border: 2px solid #ddd;
border-radius: 8px;
padding: 5px;
width: 200px;
height: 350px;
margin: 40px 40px 40px 375px;
}
.bio {
margin: 40px;
font-family: verdana;
text-align: center;
}
#biography {
font-family: arial black;
font-size: 120%;
text-align: center;
border: 2px solid #ddd;
border-radius: 8px;
padding: 10px;
}
#assignments {
font-family: arial black;
font-size: 120%;
text-align: center;
border: 2px solid #ddd;
border-radius: 8px;
padding: 10px;
}
#projects {
font-family: arial black;
font-size: 120%;
text-align: center;
border: 2px solid #ddd;
border-radius: 8px;
padding: 10px;
}
#contact {
font-family: arial black;
font-size: 100%;
text-align: center;
border: 2px solid #ddd;
border-radius: 8px;
padding: 10px;
}
.email {
border: 1px solid #ddd;
border-radius: 8px;
padding: 5px;
width: 150px;
height: 96px;
margin: 3px 40px 3px 400px;
}
.banner {
width: 960px;
height: 143px;
margin: 0 auto;
padding: 0px;
background: url(images/banner.png) no-repeat;
}
.banner h2 {
font-family: vollkorn;
font-size: 350%;
color: white;
text-transform: uppercase;
margin: 0;
position: relative;
top: -40%;
left: 83%;
transform: translate(-50%, -50%);
}
.menu {
list-style-type: none;
margin: auto;
background-color: #333;
width: 100%;
background: url(images/menu.jpg) repeat-x;
position: fixed;
min-width: 1080px;
z-index: 1;
display: inline-block;
}
.menu ul {
float: left;
margin: 0px;
padding: 0 0 0 30%;
list-style: none;
}
.menu ul li {
padding: 0px;
display: inline;
}
.menu ul li a {
position: relative;
float: center;
display: inline-block;
height: 30px;
width: 180px;
text-align: center;
padding: 12px 0 0 0;
font-size: 13px;
font-weight: bold;
text-decoration: none;
color: #ffffff;
outline: none;
min-height: 24px;
}
.menu li a:hover, .menu li .current {
position: relative;
color: #ffffff;
background: url(images/menuhoverright.jpg) top right no-repeat;
}
.menu li a:hover span, .menu li .current span {
position: absolute;
display: inline-block;
width: 15px;
height: 42px;
top: 0;
left: 0;
background: url(images/menuhoverleft.jpg) no-repeat;
}
.jprop {
border: 1px solid #ddd;
border-radius: 8px;
padding: 5px;
width: 200px;
height: 195px;
margin: 40px;
}
.jprop:hover {
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
}
<!DOCTYPE html>
<html>
<head>
<!-- Homepage
My Biography Page
Author:
Date: 01/29/2017
-->
<meta charset="UTF-8" />
<title>Homepage</title>
<script src="modernizr-1.5.js"></script>
<link href="homestyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="menu">
<img src="images/menu.jpg" alt="menu" />
<ul>
<li><span></span>Biography</li>
<li><span></span>Assignments</li>
<li><span></span>Projects</li>
<li><span></span>Contact</li>
</ul>
</div>
<div class="banner">
<img src="images/banner.png" alt="banner" />
<h2>K V</h2>
</div>
<section>
<div id="biography">
<a name="biography"><h1>Biography</h1>
</div>
<div class="biopic">
<img src="images/biopic.jpg" width="230" height="490" alt="biopic" class="bpic"/>
</div>
<article>
<div class="bio">
<p>Hello, my name is &&&&&&. --
</p>
<p>I am currently pursuing my A.S. degree in computer information technology at?I plan to start
working in the field of IT, once I obtained my A.S. degree and certifications. While working, I plan on
continuing my education to obtain my bachelor’s degree in IT at UCF. I have always had a passion for
technology, especially computers. To be able to work in the field that I enjoy is one of my life goal.
</p>
</div>
</article>
</section>
<br>
<section>
<div id="assignments">
<a name="assignments"><h1>Assignments</h1>
</div>
<div class="jprop">
<a href="Jprop/basic.html">
<img src="images/jprop.JPG" alt="jprops">
</a>
</div>
</section>
<br>
<section>
<div id="projects">
<a name="projects"><h1>Projects</h1>
</div>
</section>
<br>
<section style="max-height: 210px;">
<div id="contact">
<a name="contact"><h1>Contact</h1>
</div>
<div class="email">
<a href="mailto:REDACTED">
<img src="images/email.png" alt="emails">
</a>
</div>
</section>
<br>
</body>
</html>
This bit of css from your style sheet is going to keep the menu from resizing below 1080px. So it will be too wide for many tablets and phones for example.
.menu {
min-width: 1080px;
}
Remove the min-width property, and see if that fixes it for you.

Subitems in main menu uncentered

for some reason the subitems are not in the middle, looks like they have a margin left for some reason. Can you tell me what is wrong and how to fix it?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Responsive Menu Tutorial</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="CSS-1.css">
</head>
<body>
<ul class="egmenu">
<li>Home</li>
<li>
Products
<ul>
<li>Computers</li>
<li>Phones</li>
<li>Tablets</li>
<li>Other</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
</body>
</html>
And here is the CSS:
body {
margin: 0;
padding: 0;
}
ul.egmenu {
background: #333;
height: 30px;
width: 100%;
}
ul.egmenu > li {
float: left;
position: relative;
}
ul.egmenu ul {
background: #444;
display: none;
position: absolute;
left: 0; top: 100%;
}
ul.egmenu ul li {
text-align: center;
}
ul.egmenu a {
cursor: pointer;
display: block;
color: white;
width: 100%;
line-height: 30px;
padding: 0 10px;
text-decoration: none;
}
ul.egmenu li { list-style: none; }
ul.egmenu li:hover { background: #555; }
ul.egmenu li:hover ul { display: block; }
P.S. It would also be nice if you tell me where can i find some lessons or anything to fix my understanding of CSS, as it appears that codecademy is not enough.
You have missed some of the important attributes, i recreated your navbar
Here's the JSFiddle:https://jsfiddle.net/y2641f0w/3/
HTML
<body>
<ul class="egmenu">
<li>Home</li>
<li>
Products
<ul>
<li>Computers</li>
<li>Phones</li>
<li>Tablets</li>
<li>Other</li>
</ul>
</li>
<li>About</li>
<li>Contact</li>
</ul>
</body>
CSS
body {
margin: 0;
padding: 0;
}
ul.egmenu{
background: #333;
height: 30px;
width: 100%;
}
ul.egmenu ul {
list-style: none;
background-color: #444;
text-align: center;
padding: 0;
margin: 0;
}
ul.egmenu li {
font-size: 25px;
line-height: 30px;
text-align: left;
}
ul.egmenu a {
text-decoration: none;
color: #fff;
display: block;
padding-left: 15px;
border-bottom: 1px solid #888;
transition: .3s background-color;
}
ul.egmenu a:hover {
background-color: #555;
}
ul.egmenu a.active {
background-color: #aaa;
color: #444;
cursor: default;
}
/* Sub Menus */
ul.egmenu li li {
font-size: 15px;
}
#media screen and (min-width: 650px) {
ul.egmenu li {
width: 130px;
border-bottom: none;
height: 30px;
line-height: 30px;
font-size: 15px;
display: inline-block;
margin-right: -4px;
}
ul.egmenu a {
border-bottom: none;
}
ul.egmenu > ul > li {
text-align: center;
}
ul.egmenu > ul > li > a {
padding-left: 0;
}
/* Sub Menus */
ul.egmenu li ul {
position: absolute;
display: none;
width: inherit;
}
ul.egmenu li:hover ul {
display: block;
}
ul.egmenu li ul li {
display: block;
}
}
You can refer to followings to get more knowledge about NavBars
w3Schools
CSS Menumaker

CSS z-index with position absolute

I have simple code
The problem is the red div. It is animated but it have z-index bigger than it parent so while animating it overshadowing the main div. I can solve this problem when i give to animated div z-index: -1 but :hover doesn't work properly (animated div disappears). Anyone can help?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.main {
width: 100px;
height: 100px;
background: green;
position: relative;
}
.main .bar {
height: inherit;
width: 300px;
position: absolute;
background: red;
left: -300px;
}
.main:hover .bar {
left: 100px;
transition: left .3s;
}
</style>
</head>
<body>
<div class="main"><div class="bar"></div></div>
</body>
</html>
https://jsfiddle.net/24qbyh4p/
The solution is wrapping the contents of .main in an inner container with a z-index greater than .bar's one.
.main {
width: 100px;
height: 100px;
position: relative;
}
.main > .bar {
height: inherit;
width: 300px;
position: absolute;
background: red;
left: -300px;
}
.main > .content {
height: 100%;
background: green;
position: relative;
z-index: 1;
}
.main:hover .bar {
left: 100px;
transition: left .3s;
}
<div class="main">
<div class="bar"></div>
<div class="content"></div>
</div>

how to center my navigation

I am having problem with centering the navigation. Tried all possible ways. Unable to center it. Wondering what might be affecting? Do I need to target .nav only? Or container too? My website :
HTML
<div id="navcontainer">
<a class="toggleMenu" href="#">Menu</a>
<ul class="nav">
<li class="test">
<li>PRADŽIA</li>
<li>APIE MUS</li>
<li>KAINOS</li>
<li>ASMENINĖS
<ul>
<li>Asmeninė fotosesija</li>
<li>Poros fotosesija</li>
<li>Šeimos fotosesija</li>
<li>Nėščiosios fotosesija</li>
<li>Vaikų fotosesija</li>
<li>Draugų fotosesija</li>
<li>Erotinė fotosesija</li>
<li>Švencių fotosesija</li>
<li>Modelio testas</li>
</ul>
</li>
<li>KŪRYBINĖS</li>
<li>ATSILIEPIMAI</li>
<li>KONTAKTAI</li>
</li>
</ul>
</div>
</div><!--/navcontainer-->
CSS
/*---- NAVIGATION -------*/
#navcontainer{
float: left;
width:100%;
padding: 10px 0 10px 0;
font-size:1.2em;
background: #ccc;
}
.toggleMenu {
display: none;
padding: 10px 15px;
color: #fff;
background:#383636;
}
.nav {
list-style: none;
*zoom: 1;
background: blue;
margin: 0 auto;
}
.nav:before,
.nav:after {
content: " ";
display: table;
}
.nav:after {
clear: both;
}
.nav ul {
display: inline-block;
list-style-type: none;
width: 9em;
}
.nav a {
display: inline-block;
padding: 10px 15px;
color:#383636;
text-decoration:none;
}
.nav li {
position: relative;
display: inline;
}
.nav > li {
float: left;
}
.nav > li > .parent {
background-repeat: no-repeat;
background-position: right;
}
.nav > li > a {
display: block;
}
.nav li ul {
position: absolute;
left: -9999px;
}
.nav > li.hover > ul {
left: 0;
}
.nav li li.hover ul {
left: 100%;
top: 0;
}
.nav li li a {
display: block;
background: #efefef;
position: relative;
z-index:100;
border-top: 1px solid #ccc;
}
#navcontainer ul li a:hover{
color: #fff;
background: #ccc;
}
#navcontainer ul li a#current{
color: #fff;
background: #ccc;
}
try to add this to your NAV-CONTAINER: margin:0px auto;
Try this :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
/*---- NAVIGATION -------*/
#navcontainer{
width:100%;
padding: 10px 0 10px 0;
font-size:1.2em;
background: #ccc;
margin: 0 auto;
text-align: center;
}
.toggleMenu {
display: none;
padding: 10px 15px;
color: #fff;
background:#383636;
}
.nav {
display: inline-block;
list-style: none;
background: #AE4532;
}
ul {
display: inline-block;
list-style-type: none;
width: auto;
}
.nav a {
display: inline-block;
padding: 10px 15px;
color:#3EBD36;
text-decoration:none;
margin: 10px
}
li {
position: relative;
/* display: inline;*/
float: left;
}
.nav li ul {
position: absolute;
width: 100%;
left: -9999px;
}
</style>
</head>
<body>
<div id="navcontainer">
<a class="toggleMenu" href="#">Menu</a>
<ul class="nav">
<li>PRADŽIA</li>
<li>APIE MUS</li>
<li>KAINOS</li>
<li>ASMENINĖS
<ul>
<li>Asmeninė fotosesija</li>
<li>Poros fotosesija</li>
<li>Šeimos fotosesija</li>
<li>Nėščiosios fotosesija</li>
<li>Vaikų fotosesija</li>
<li>Draugų fotosesija</li>
<li>Erotinė fotosesija</li>
<li>Švencių fotosesija</li>
<li>Modelio testas</li>
</ul>
</li>
<li>KŪRYBINĖS</li>
<li>ATSILIEPIMAI</li>
<li>KONTAKTAI</li>
</ul>
</div>
</body>
</html>

Resources