Why is scrolling inconsistent between Firefox, Safari and Chrome? - javascript
I'm working on this web page at http://helpir-staging.herokuapp.com. It isn't perfect but it scrolls fine on Safari. In Firefox it only scrolls using the arrow keys (no mouse scroll), and in Chrome I don't get any scroll at all.
There must be something horrifically wrong in my CSS. Any help would be really appreciated.
I'm using bootstrap, bootcards, angularjs and angular-dynamic-layout.
app.scss:
$icon-font-path: "../bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/";
$hero-image: "../assets/images/slider.jpg";
#import '../bower_components/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap';
#import '../bower_components/bootstrap-social/bootstrap-social.scss';
$fa-font-path: "../bower_components/font-awesome/fonts";
#import '../bower_components/font-awesome/scss/font-awesome';
// App-wide Styles
.browserupgrade {
margin: 0.2em 0;
background: #ccc;
color: #000;
padding: 0.2em 0;
}
// KAREL CSS
$heynay-background: #FAFAFA;
$heynay-peach: #f27949;
$helpir-gray: rgba(255,255,255,0.5);
html, body {
height: 100%;
width: 100%;
// background-color: blue;
}
h1 {
font-size: 2em;
}
p {
font-size: 0.85em;
}
hr {
display: none;
}
body {
font-family: Futura, 'Trebuchet MS', Arial, sans-serif;
}
.alert {
margin: 10px 0px;
}
.margined {
margin: 5px;
}
.navbar-default,
.navbar-default .navbar-nav>li>a,
.navbar-default .navbar-text
{
color: #eeeeee;
background-color: transparent;
}
.footer > p,
.footer > p > a,
{
color: #888888;
background-color: transparent;
}
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>li>a.active,
.navbar-default .navbar-nav>li>a:focus ,
.navbar-default .navbar-nav>li>a>p.active ,
.navbar-default .navbar-nav>li>a>p:focus {
border-radius: 3px;
color: #111111;
background-color: $helpir-gray;
}
#profile-button {
margin: 0px;
padding: 12px 5px;
height: 50px;
}
#profile-button:hover,
#profile-button.active {
border-radius: 3px;
color: white;
background-color: $heynay-peach;
}
.navbar-default .navbar-nav>li>a>p {
color: white;
background: none;
margin: 0px;
padding: 0px;
}
.navbar-default .navbar-nav>li>a>p>img {
height: 30px;
width: 30px;
padding: 3px;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: white;
}
.btn-default {
color: #000;
background-color: $heynay-peach;
}
.btn-default {
color: #f00;
background-color: $heynay-peach;
}
.btn-default[disabled] {
background-color: #9B9B9B;
}
.btn-default:hover {
background-color: $heynay-background;
color: white;
}
.btn {
display: inline-block;
padding: 6px 12px;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 0px solid transparent;
border-radius: 4px;
}
.icon-brand {
color: $heynay-background;
}
.heynay-legal {
text-align: left;
}
.panel-default > .panel-heading {
background: $heynay-background;
}
.panel-title > a,
.panel-title > a {
text-decoration: none;
color: white;
}
.panel-title > a:hover,
.panel-title > a.active {
text-decoration: none;
color: black;
}
[ng-click],
[data-ng-click],
[x-ng-click] {
cursor: pointer;
}
// GLOBAL STYLES
footer {
height: 60px;
text-align: center;
background-color: $heynay-background;
padding-top:20px;
padding-bottom:20px;
font-size: 0.8em;
}
#heynay-logo {
font-size: 25px;
color: #000000;
}
.navbar-toggle {
background-color: $heynay-peach;
border-color: transparent;
}
.desktop-footer {
display : none;
}
.mobile-footer {
display : inline;
}
// not sure if tyhis is used.
.general-section {
text-align: left;
padding: 50px 10px;
min-height: 75%;
font-size: 0.9em;
}
.floating-pane-holder {
display: none;
z-index:1000;
color: white;
background-color: $heynay-peach;
position: fixed;
height: 50px;
width: 90px;
top: 100px;
left: 48%;
transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
.floating-pane-content {
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
position: absolute;
}
#media(min-width: 450px) {
.navbar-default,
.navbar-default .navbar-nav>li>a,
.footer > p,
.footer > p > a
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
font-size: 0.95em;
border-color: transparent;
}
h1 {
font-size: 3em;
}
p {
font-size: 1em;
}
hr {
display: block;
}
}
#media(min-width:1000px) {
.navbar-default,
.navbar-default .navbar-nav>li>a,
.footer > p,
.footer > p > a
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:focus,
.navbar-default .navbar-nav>.active>a:hover {
font-size: 1em;
border-color: transparent;
}
#heynay-logo {
font-size: 35px;
}
}
// TABLES
.desktop-table {
display : none;
}
.mobile-table {
display : inline;
}
// TABLES END
// MODAL BEGIN
.ngdialog.ngdialog-theme-default
.ngdialog-content {
width: 700px;
}
// MODAL END
#media(min-width:750px) {
.navbar {
padding: 20px 0;
background-color: transparent;
-webkit-transition: background .35s ease-in-out,padding .5s ease-in;
-moz-transition: background .35s ease-in-out,padding .5s ease-in;
transition: background .35s ease-in-out,padding .5s ease-in;
border-color: transparent;
}
.desktop-footer {
display : inline;
}
.mobile-footer {
display : none;
}
.top-nav-collapse {
padding: 0;
background-color: $heynay-background;
}
footer {
height: 60px;
font-size: 1em;
bottom:0;
height:2em;
}
.general-section {
padding: 100px 10px;
font-size: 1em;
}
.navbar-default .navbar-nav>li>p {
padding: 15px;
margin: 0px;
border-color: transparent;
}
}
#media(min-width: 900px) {
.desktop-table {
display : inline;
}
.floating-pane-holder {
top: 150px;
left: 10px;
transform: none;
-webkit-transform: none;
}
.mobile-table {
display : none;
}
}
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
// SPINNER
.spinner {
margin: 100px auto 0;
margin-bottom: 100px;
width: 70px;
text-align: center;
}
.spinner > div {
width: 18px;
height: 18px;
background-color: $heynay-background;
border-radius: 100%;
display: inline-block;
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
animation: bouncedelay 1.4s infinite ease-in-out;
// Prevent first frame from flickering when animation starts
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.spinner .bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.spinner .bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
#-webkit-keyframes bouncedelay {
0%, 80%, 100% { -webkit-transform: scale(0.0) }
40% { -webkit-transform: scale(1.0) }
}
#keyframes bouncedelay {
0%, 80%, 100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
} 40% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
// Component styles are injected through grunt
// injector
#import 'admin/admin.scss';
#import 'main/main.scss';
#import '../components/category-tile/category-tile.scss';
#import '../components/footer/footer.scss';
#import '../components/modal/modal.scss';
#import '../components/oauth-buttons/oauth-buttons.scss';
// endinjector
category-tile.css
// dynamic layout bits...
#media (min-width: 1000px) {
[dynamic-layout] {
width: 1000px;
margin-top: 25px;
}
.dynanamic-layout-col-4 {
width: 250px;
margin-top: 20px;
}
.dynamic-layout-col-8 {
width: 500px;
}
}
#media (min-width: 900px) {
[dynamic-layout]{
width: 900px;
margin-top: 20px;
}
.dynamic-layout-col-4{
width : 300px;
}
.dynamic-layout-col-8{
width : 600px;
}
}
#media (min-width: 600px) and (max-width: 900px){
[dynamic-layout]{
width: 600px;
margin-top: 8px;
}
.dynamic-layout-col-4{
width : 300px;
}
.dynamic-layout-col-8{
width : 600px;
}
}
#media (max-width: 600px){
[dynamic-layout]{
width: 300px;
margin-top: 6px;
}
.dynamic-layout-col-4{
width : 300px;
}
.dynamic-layout-col-8{
width : 300px;
}
}
.dynamic-layout-item {
padding: 10px;
width: auto;
}
.move-items-animation{
transition-property: left, top;
transition-duration: .25s;
transition-timing-function: ease-in-out;
}
.dynamic-layout-item-parent.ng-enter{
transition: .25s ease-in-out;
opacity:0;
}
.dynamic-layout-item-parent.ng-enter.ng-enter-active{
opacity:1;
}
.dynamic-layout-item-parent.ng-leave{
transition: .5s ease-in-out;
opacity:1;
}
.dynamic-layout-item-parent.ng-leave.ng-leave-active{
opacity:0;
}
[dynamic-layout]{
// float: left;
position: absolute;
// overflow: hidden;
// height: 1000px;
}
.container-fluid{
position: absolute;
left: 50%;
transform: translate(-50%);
height:auto;
}
.title {
// margin-bottom: 50px;
}
main.css
.thing-form {
margin: 20px 0;
}
#banner {
border-bottom: none;
margin-top: -45px;
}
#banner h1 {
font-size: 60px;
line-height: 1;
letter-spacing: -1px;
}
.hero-unit {
background-image: url("#{$hero-image}");
position: relative;
# padding: 30px 15px;
color: #F5F5F5;
# background: #4393B9;
background-size:cover;
background-repeat: no-repeat;
color: #fff;
cursor: default;
padding: 1em 0 0 0;
}
.header-text {
text-align: center;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
cursor: default;
position: relative;
}
.navbar-text {
margin-left: 15px;
}
.privacy-terms {
margin-top: 75px;
}
.support-section {
padding-top: 150px;
text-align: center;
min-height: 85%;
}
#media(min-width: 400px) {
.intro-section {
// background: url("#{$hero-image}") no-repeat 98% 30%;
}
}
#media(min-width: 750px) {
.intro-section {
padding-top: 150px;
}
}
Your script vendor (idk what it is) is breaking it, in chrome under inspect I see this:
body, html {
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
}
change hidden to visible and it works, at least in chrome. initialize your custom css file after the vendor script and the css property should be fixed.
Related
Why is "keyframes method" not working the way it should in my css?
In the keyframes part, my PC doesn't recognize the from part. If it would, it would be blue and the opacity command would be grey. But as you see none of them is correct and I don't know why. Because of this little error, my HTML website is not working the way it should. Can anyone please help me? I would like to finish my HTML website. body { margin: 0; padding: 0; animation: bgcolor infinite 20s; } h1 { font-family: 'Yeseva One', cursive; font-size: 4em; margin: 0; color: #fff; } #keyframes bgcolor { 0% { background: #f1c40f; } 10% { background: #f39c12; } 20% { background: #e67e22; } 30% { background: #d35400; } 40% { background: #e74c3c; } 50% { background: #c0392b; } 60% { background: #e74c3c; } 70% { background: #d35400; } 80% { background: #e67e22; } 90% { background: #f39c12; } 100% { background: #f1c40f; } } h2 { font-family: 'IM Fell DW Pica', serif; font-size: 3em; margin: 0; color: #fff; } p { font-family: 'Clicker Script', cursive; font-size: 2em; margin: 0; color: #fff; } button { font-family: 'Playfair Display SC', serif; font-size: 1em; } button { margin: 0; border: none; background: #ea1538; padding: 12px 30px; border-radius: 30px; color: white; font-weight: bold; box-sizing: border-box; transition: .3s } button:hover { transform: scale(1.3); cursor: pointer; } .hero { height: 100vh; width: 100%; } nav { display: flex; align-items: center; min-height: 8vh; justify-content: space-between; padding-left: 25%; padding-right: 10%; } .logo { color: white; font-size: 28px; } .nav-links { display: flex; justify-content: space-between; } .nav-links a { text-decoration: none; letter-spacing: 1px; } .line { width: 100%; height: 3px; background-color: white; margin: 5px; } .burger { display: none; cursor: pointer; } .burger div { width: 25px; height: 3px; background-color: white; margin: 5px; } span { color: #000000; } nav ul li { list-style-type: none; display: inline-block; padding: 10px 20px; font-size: 19px; } nav ul li a { color: white; text-decoration: none; font-weight: bold; } nav ul li a:hover { color: #000000; transition: .2s; } #media screen and (max-width:1024px) { .nav-links { display: flex; justify-content: space-between; width: 60%; } } #media screen and (max-width:768px) { body { overflow-x: hidden; } .nav-links { position: absolute; background-color: #ffeaa7; /*just to see if the slider works*/ right: 0px; height: 100vh; top: 18vh; display: flex; flex-direction: column; align-items: center; width: 40%; transform: translateX(100%); transition: transform 0.5s ease-in; } .nav-links li { opacity: 0; } .burger { padding-left: 100%; display: block; } } .nav-active { transform: translateX(0%); } #keyframes navLinkFade { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0px); } }
I'm not sure I fully understand your question, it might be helpful to reframe it, with a minimal reproducible example. See StackOverflows MRE I don't see you calling the animation anywhere in your code. You need to target the nav links, and tell it to use the animation navLinkFade. Here is an example of a super simple animation. ul { animation: fade 3s forwards; } #keyframes fade { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0px); } } <ul> <li>Test</li> <li>Test</li> </ul>
Why my font color in navbar didn't change when i toggle to sticky?
I'm still new to css and tried to make a sticky navbar with background of white color and black font. I'm struggling to find the solution and can't figure out what's wrong. Here's my what my initial navbar looks like initial navbar And here's scrolled navbar Scrolled Navbar The picture isn't clear but the font is still white with a little black outline even though i changed the font color to black Here's my HTML code: <header id='navbar'> LOGO <div class="menu"> <div class="btn"> <i class="fas fa-times close-btn"></i> </div> Jadi Partner Lapangan Favorit Pesanan Saya <div class="dropdown"> <button class="dropbtn"> <i class="fas fa-bars" id="menu-dropdown"></i><i class="fas fa-user-circle"></i> </button> <div class="dropdown-content"> Log In Sign Up </div> </div> </div> <div class="btn"> <i class="fas fa-bars menu-btn"></i> </div> </header> <script type="text/javascript"> window.addEventListener('scroll', function () { // var header = document.querySelector('header'); var header = document.querySelector('header'); header.classList.toggle('sticky', window.scrollY > 0); }) </script> <script type="text/javascript"> //Javacript of responsive navigation menu const menuBtn = document.querySelector(".menu-btn"); const navigation = document.querySelector(".navigation"); menuBtn.addEventListener("click", () => { menuBtn.classList.toggle("active"); navigation.classList.toggle("active"); }); </script> and this is the CSS part: * { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; } header{ z-index: 999; position: fixed; top: 0; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 20px 100px; transition: 0.6s; } header.sticky { background: #ffffff; padding: 20px 100px; } header .brand{ color: #fff; font-size: 30px; font-weight: 700; text-transform: uppercase; text-decoration: none; letter-spacing: 2px; } header .menu{ position: relative; display: flex; justify-content: center; align-items: center; } header .menu a{ color: rgb(255, 255, 255); font-size: 16px; font-weight: 500; text-decoration: none; margin: 0 30px; padding: 0 10px; border-radius: 20px; transition: 0.3s; transition-property: color, background; } header.sticky .menu a{ color: black !important; z-index: 9999999; } header .menu a:hover{ color: #000; background: #fff; } header .btn{ color: #fff; font-size: 25px; cursor: pointer; display: none; } .dropdown { float: right; position: relative; /* overflow: hidden; */ margin-left: 10px; } .dropdown .dropbtn { font-size: 16px; border: none; outline: none; font-family: inherit; margin-left: 20px; color: black; background-color: #fff; border-radius: 30px; padding: 0 3px; } .dropdown-content { display: none; position: absolute; top: calc(100%); right: 0; background-color: #ffffff; max-width: 160px; /* box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); */ z-index: 9999; border-radius: 10px; } .dropdown-content a { /* float: none; */ color: black !important; margin: 5px 0 !important; padding: 6px 10px; min-width: 120px; text-decoration: none; display: inline-block; font-size: .8em !important; /* text-align: left; */ /* overflow: hidden; */ } .dropdown-content a:hover { background-color: rgb(212, 212, 212); } .dropdown:hover .dropdown-content { display: block; } .navigation-items { display: flex; justify-content: center; align-items: center; } header .navigation .navigation-items #profile-dropdown { color: black; background-color: #fff; border-radius: 30px; padding: 0 3px; } .dropbtn i { margin: 0 3px; } #menu-dropdown { font-size: .7em; } header ul li a:before { content: ''; position: absolute; background: rgb(255, 255, 255); border-color: #000000; width: 0; height: 3px; bottom: 0; left: 0; transition: 0.3s ease; } header ul li a:hover:before { width: 100%; } This part is edited I found out that with only navbar it works perfectly fine, but the problem occure when i add background image below navbar. Here's my background code below navbar: <section class="home"> <div class="images-home"> <img src="{% static 'main/images/basketball.jfif' %}" alt="" class="image-slide"> <img src="{% static 'main/images/prapoth-panchuea-OMWubltUEfE-unsplash.jpg' %}" alt="" class="image-slide"> <img src="{% static 'main/images/muktasim-azlan-rjWfNR_AC5g-unsplash.jpg' %}" alt="" class="image-slide"> </div> <div class="content"> <h1>Train. Grow. Repeat.<br></h1> <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Maiores magnam quia vitae, animi unde consequuntur nihil doloribus quidem culpa, voluptatem, harum consequatur laboriosam delectus officia!</p> <a href="#"> <span></span> <span></span> <span></span> <span></span> Booking sekarang</a> </div> <div class="slider-navigation"> <div onclick="slider_nav(1)" class="nav-btn" id="radio1"></div> <div onclick="slider_nav(2)" class="nav-btn" id="radio2"></div> <div onclick="slider_nav(3)" class="nav-btn" id="radio3"></div> </div> </section> and here's CSS for background: section { padding: 100px 200px; } .home { position: relative; width: 100%; min-height: 100vh; display: flex; justify-content: center; flex-direction: column; /* background: #267be9; */ background: #ED1E1E; } .home:before { z-index: 777; content: ''; position: absolute; /* background: rgba(62, 129, 245, 0.3); */ background: rgba(212, 11, 11, 0.3); width: 100%; height: 100%; top: 0; left: 0; } .home .content { z-index: 888; /* color: #fff; */ color: #fff; width: 60%; margin: 50px 70px; position: absolute; left: 0%; } .home .content h1 { font-size: 3.5em; font-weight: 700; /* text-transform: uppercase; */ letter-spacing: 5px; line-height: 75px; margin-bottom: 40px; } .home .content p { margin-bottom: 65px; max-width: 50%; /* font-size: 1.2vw; */ } .home .content a { /* background: #fff; */ width: 30%; background: #ED1E1E; padding: 15px 35px; /* color: #1680AC; */ /* color: #ED1E1E; */ color: #ffffff; /* font-size: 1.1em; */ font-size: 1.4vw; font-weight: 500; text-decoration: none; text-transform: uppercase; position: relative; /* display: flex; */ } .home .content a:hover { color: var(--main-color); background-color: #fff; } .home .content a span { display: block; position: absolute; background: var(--main-color); } .home .content a span:nth-child(1) { left: 0; bottom: 0; width: 2px; height: 100%; transform: scaleY(0); transform-origin: top; transition: transform 0.5s; } .home .content a:hover span:nth-child(1) { transform: scaleY(1); transform-origin: bottom; transition: transform 0.5s; } .home .content a span:nth-child(2) { left: 0; bottom: 0; width: 100%; height: 2px; transform: scaleX(0); transform-origin: right; transition: transform 0.5s; } .home .content a:hover span:nth-child(2) { transform: scaleX(1); transform-origin: left; transition: transform 0.5s; } .home .content a span:nth-child(3) { right: 0; bottom: 0; width: 2px; height: 100%; transform: scaleY(0); transform-origin: top; transition: transform 0.5s; transition-delay: 0.5s; } .home .content a:hover span:nth-child(3) { transform: scaleY(1); transform-origin: bottom; transition: transform 0.5s; transition-delay: 0.5s; } .home .content a span:nth-child(4) { left: 0; top: 0; width: 100%; height: 2px; transform: scaleX(0); transform-origin: right; transition: transform 0.5s; transition-delay: 0.5s; } .home .content a:hover span:nth-child(4) { transform: scaleX(1); transform-origin: left; transition: transform 0.5s; transition-delay: 0.5s; } .home img { z-index: 000; position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; } .home .media-icons { z-index: 888; position: absolute; right: 30px; display: flex; flex-direction: column; transition: 0.5s ease; } .home .media-icons a { color: #fff; font-size: 1.6em; transition: 0.3s ease; } .home .media-icons a:not(:last-child) { margin-bottom: 20px; } .home .media-icons a:hover { transform: scale(1.3); } .slider-navigation { z-index: 888; position: absolute; display: flex; justify-content: center; align-items: center; /* transform: translateY(80px); */ /* margin-bottom: 12px; */ bottom: 5%; left: 50%; transform: translateX(-50%); } .slider-navigation .nav-btn { width: 12px; height: 12px; background: #fff; border-radius: 50%; cursor: pointer; box-shadow: 0 0 2px rgba(255, 255, 255, 0.5); transition: 0.3s ease; } .slider-navigation .nav-btn:not(:last-child) { margin-right: 20px; } .slider-navigation .nav-btn:hover { transform: scale(1.2); } .slider-navigation .nav-btn.active { background: var(--main-color); } #media (max-width: 1040px) { section { padding: 100px 20px; } .home .content { margin: 0 20px; } .home .media-icons { right: 15px; } .home .content h1 { font-size: 4vw; line-height: 60px; } .home .content p { margin-bottom: 65px; max-width: 40%; font-size: 13px; } } #media (max-width: 560px) { .home .content { margin: 0 20px; } .home .content h1 { /* font-size: 2em; */ line-height: 60px; } .home .content p { margin-bottom: 65px; max-width: 40%; font-size: 10px; } .home .content a { max-width: 10px; padding: 10px 25px; } } I read something about !important, but it dind't help. Thank you for anyone who are willing to help an amateur like me :)
You need to add background-color and color property to the header selector not header .sticky. As you're dynamically adding the sticky class, so at first render the colors are not actually visible. UPDATE Checked your codepen and you're missing the property when .sticky class is applied via JS header.sticky .dropdown .dropbtn { background-color: #000; } header.sticky .brand{ color: #000; }
Getting Invalid LatLng object when trying to map coordinates using leaflet
I'm trying to figure out how I can loop each of the coordinates, <div class="map-container" id="mapid"></div> <ul class="plot"> <li class="markers" data-lattitude="-40.99497" data-longitude="174.50808">Text 1</li> <li class="markers" data-lattitude="-41.30269" data-longitude="173.63696">Text 2</li> <li class="markers" data-lattitude="-41.49413" data-longitude="173.5421">Text 3</li> <li class="markers" data-lattitude="-40.98585" data-longitude="174.50659">Text 4</li> <li class="markers" data-lattitude="-40.93163" data-longitude="173.81726">Text 5</li> </ul> add them to an array, plot them on the map with the popup text shown. Below is an error that I can't seem to solve. not sure which part of the code is wrong. leaflet.js:5 Uncaught Error: Invalid LatLng object: (e, x) Below is the sample of the code that I have been working on. var map = L.map('mapid', { fullscreenControl: { pseudoFullscreen: false // if true, fullscreen to page width and height }, }).setView([30.539255791073, 58.383450508118], 5); map.createPane('labels'); map.getPane('labels').style.zIndex = 650; map.getPane('labels').style.pointerEvents = 'none'; var positron = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { noWrap: true, maxZoom : 10 }).addTo(map); var positronLabels = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', { pane: 'labels', noWrap: true, maxZoom : 3 }).addTo(map); var southWest = L.latLng(-89.98155760646617, -180), northEast = L.latLng(89.99346179538875, 180), bounds = L.latLngBounds(southWest, northEast); map.setMaxBounds(bounds); map.on('drag', function() { map.panInsideBounds(bounds, { animate: false }); }); var plot = []; $('.plot > .markers').each(function() { plot.push($(this).text(), $(this).data('lattitude'), $(this).data('longitude') ); }); console.log( plot ); for ( var i = 0; i < plot.length; i++ ) { marker = new L.marker([plot[i][1], plot[i][2]]).bindPopup(plot[i][0], {autoClose:false}).addTo(map).openPopup(); } /* required styles */ .leaflet-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-tile-container, .leaflet-pane > svg, .leaflet-pane > canvas, .leaflet-zoom-box, .leaflet-image-layer, .leaflet-layer { position: absolute; left: 0; top: 0; } .leaflet-container { overflow: hidden; } .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow { -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-user-drag: none; } /* Safari renders non-retina tile on retina better with this, but Chrome is worse */ .leaflet-safari .leaflet-tile { image-rendering: -webkit-optimize-contrast; } /* hack that prevents hw layers "stretching" when loading new tiles */ .leaflet-safari .leaflet-tile-container { width: 1600px; height: 1600px; -webkit-transform-origin: 0 0; } .leaflet-marker-icon, .leaflet-marker-shadow { display: block; } /* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ /* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ .leaflet-container .leaflet-overlay-pane svg, .leaflet-container .leaflet-marker-pane img, .leaflet-container .leaflet-shadow-pane img, .leaflet-container .leaflet-tile-pane img, .leaflet-container img.leaflet-image-layer, .leaflet-container .leaflet-tile { max-width: none !important; max-height: none !important; } .leaflet-container.leaflet-touch-zoom { -ms-touch-action: pan-x pan-y; touch-action: pan-x pan-y; } .leaflet-container.leaflet-touch-drag { -ms-touch-action: pinch-zoom; /* Fallback for FF which doesn't support pinch-zoom */ touch-action: none; touch-action: pinch-zoom; } .leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { -ms-touch-action: none; touch-action: none; } .leaflet-container { -webkit-tap-highlight-color: transparent; } .leaflet-container a { -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4); } .leaflet-tile { filter: inherit; visibility: hidden; } .leaflet-tile-loaded { visibility: inherit; } .leaflet-zoom-box { width: 0; height: 0; -moz-box-sizing: border-box; box-sizing: border-box; z-index: 800; } /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ .leaflet-overlay-pane svg { -moz-user-select: none; } .leaflet-pane { z-index: 400; } .leaflet-tile-pane { z-index: 200; } .leaflet-overlay-pane { z-index: 400; } .leaflet-shadow-pane { z-index: 500; } .leaflet-marker-pane { z-index: 600; } .leaflet-tooltip-pane { z-index: 650; } .leaflet-popup-pane { z-index: 700; } .leaflet-map-pane canvas { z-index: 100; } .leaflet-map-pane svg { z-index: 200; } .leaflet-vml-shape { width: 1px; height: 1px; } .lvml { behavior: url(#default#VML); display: inline-block; position: absolute; } /* control positioning */ .leaflet-control { position: relative; z-index: 800; pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ pointer-events: auto; } .leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; } .leaflet-top { top: 0; } .leaflet-right { right: 0; } .leaflet-bottom { bottom: 0; } .leaflet-left { left: 0; } .leaflet-control { float: left; clear: both; } .leaflet-right .leaflet-control { float: right; } .leaflet-top .leaflet-control { margin-top: 10px; } .leaflet-bottom .leaflet-control { margin-bottom: 10px; } .leaflet-left .leaflet-control { margin-left: 10px; } .leaflet-right .leaflet-control { margin-right: 10px; } /* zoom and fade animations */ .leaflet-fade-anim .leaflet-tile { will-change: opacity; } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-map-pane .leaflet-popup { opacity: 1; } .leaflet-zoom-animated { -webkit-transform-origin: 0 0; -ms-transform-origin: 0 0; transform-origin: 0 0; } .leaflet-zoom-anim .leaflet-zoom-animated { will-change: transform; } .leaflet-zoom-anim .leaflet-zoom-animated { -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); transition: transform 0.25s cubic-bezier(0,0,0.25,1); } .leaflet-zoom-anim .leaflet-tile, .leaflet-pan-anim .leaflet-tile { -webkit-transition: none; -moz-transition: none; transition: none; } .leaflet-zoom-anim .leaflet-zoom-hide { visibility: hidden; } /* cursors */ .leaflet-interactive { cursor: pointer; } .leaflet-grab { cursor: -webkit-grab; cursor: -moz-grab; cursor: grab; } .leaflet-crosshair, .leaflet-crosshair .leaflet-interactive { cursor: crosshair; } .leaflet-popup-pane, .leaflet-control { cursor: auto; } .leaflet-dragging .leaflet-grab, .leaflet-dragging .leaflet-grab .leaflet-interactive, .leaflet-dragging .leaflet-marker-draggable { cursor: move; cursor: -webkit-grabbing; cursor: -moz-grabbing; cursor: grabbing; } /* marker & overlays interactivity */ .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-image-layer, .leaflet-pane > svg path, .leaflet-tile-container { pointer-events: none; } .leaflet-marker-icon.leaflet-interactive, .leaflet-image-layer.leaflet-interactive, .leaflet-pane > svg path.leaflet-interactive { pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ pointer-events: auto; } /* visual tweaks */ .leaflet-container { background: #ddd; outline: 0; } .leaflet-container a { color: #0078A8; } .leaflet-container a.leaflet-active { outline: 2px solid orange; } .leaflet-zoom-box { border: 2px dotted #38f; background: rgba(255,255,255,0.5); } /* general typography */ .leaflet-container { font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } /* general toolbar styles */ .leaflet-bar { box-shadow: 0 1px 5px rgba(0,0,0,0.65); border-radius: 4px; } .leaflet-bar a, .leaflet-bar a:hover { background-color: #fff; border-bottom: 1px solid #ccc; width: 26px; height: 26px; line-height: 26px; display: block; text-align: center; text-decoration: none; color: black; } .leaflet-bar a, .leaflet-control-layers-toggle { background-position: 50% 50%; background-repeat: no-repeat; display: block; } .leaflet-bar a:hover { background-color: #f4f4f4; } .leaflet-bar a:first-child { border-top-left-radius: 4px; border-top-right-radius: 4px; } .leaflet-bar a:last-child { border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-bottom: none; } .leaflet-bar a.leaflet-disabled { cursor: default; background-color: #f4f4f4; color: #bbb; } .leaflet-touch .leaflet-bar a { width: 30px; height: 30px; line-height: 30px; } .leaflet-touch .leaflet-bar a:first-child { border-top-left-radius: 2px; border-top-right-radius: 2px; } .leaflet-touch .leaflet-bar a:last-child { border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } /* zoom control */ .leaflet-control-zoom-in, .leaflet-control-zoom-out { font: bold 18px 'Lucida Console', Monaco, monospace; text-indent: 1px; } .leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { font-size: 22px; } /* layers control */ .leaflet-control-layers { box-shadow: 0 1px 5px rgba(0,0,0,0.4); background: #fff; border-radius: 5px; } .leaflet-control-layers-toggle { background-image: url(images/layers.png); width: 36px; height: 36px; } .leaflet-retina .leaflet-control-layers-toggle { background-image: url(images/layers-2x.png); background-size: 26px 26px; } .leaflet-touch .leaflet-control-layers-toggle { width: 44px; height: 44px; } .leaflet-control-layers .leaflet-control-layers-list, .leaflet-control-layers-expanded .leaflet-control-layers-toggle { display: none; } .leaflet-control-layers-expanded .leaflet-control-layers-list { display: block; position: relative; } .leaflet-control-layers-expanded { padding: 6px 10px 6px 6px; color: #333; background: #fff; } .leaflet-control-layers-scrollbar { overflow-y: scroll; overflow-x: hidden; padding-right: 5px; } .leaflet-control-layers-selector { margin-top: 2px; position: relative; top: 1px; } .leaflet-control-layers label { display: block; } .leaflet-control-layers-separator { height: 0; border-top: 1px solid #ddd; margin: 5px -10px 5px -6px; } /* Default icon URLs */ .leaflet-default-icon-path { background-image: url(images/marker-icon.png); } /* attribution and scale controls */ .leaflet-container .leaflet-control-attribution { background: #fff; background: rgba(255, 255, 255, 0.7); margin: 0; } .leaflet-control-attribution, .leaflet-control-scale-line { padding: 0 5px; color: #333; } .leaflet-control-attribution a { text-decoration: none; } .leaflet-control-attribution a:hover { text-decoration: underline; } .leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-scale { font-size: 11px; } .leaflet-left .leaflet-control-scale { margin-left: 5px; } .leaflet-bottom .leaflet-control-scale { margin-bottom: 5px; } .leaflet-control-scale-line { border: 2px solid #777; border-top: none; line-height: 1.1; padding: 2px 5px 1px; font-size: 11px; white-space: nowrap; overflow: hidden; -moz-box-sizing: border-box; box-sizing: border-box; background: #fff; background: rgba(255, 255, 255, 0.5); } .leaflet-control-scale-line:not(:first-child) { border-top: 2px solid #777; border-bottom: none; margin-top: -2px; } .leaflet-control-scale-line:not(:first-child):not(:last-child) { border-bottom: 2px solid #777; } .leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-bar { box-shadow: none; } .leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-bar { border: 2px solid rgba(0,0,0,0.2); background-clip: padding-box; } /* popup */ .leaflet-popup { position: absolute; text-align: center; margin-bottom: 20px; } .leaflet-popup-content-wrapper { padding: 1px; text-align: left; border-radius: 12px; } .leaflet-popup-content { margin: 13px 19px; line-height: 1.4; } .leaflet-popup-content p { margin: 18px 0; } .leaflet-popup-tip-container { width: 40px; height: 20px; position: absolute; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; } .leaflet-popup-tip { width: 17px; height: 17px; padding: 1px; margin: -10px auto 0; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: white; color: #333; box-shadow: 0 3px 14px rgba(0,0,0,0.4); } .leaflet-container a.leaflet-popup-close-button { position: absolute; top: 0; right: 0; padding: 4px 4px 0 0; border: none; text-align: center; width: 18px; height: 14px; font: 16px/14px Tahoma, Verdana, sans-serif; color: #c3c3c3; text-decoration: none; font-weight: bold; background: transparent; } .leaflet-container a.leaflet-popup-close-button:hover { color: #999; } .leaflet-popup-scrolled { overflow: auto; border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; } .leaflet-oldie .leaflet-popup-content-wrapper { zoom: 1; } .leaflet-oldie .leaflet-popup-tip { width: 24px; margin: 0 auto; -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); } .leaflet-oldie .leaflet-popup-tip-container { margin-top: -1px; } .leaflet-oldie .leaflet-control-zoom, .leaflet-oldie .leaflet-control-layers, .leaflet-oldie .leaflet-popup-content-wrapper, .leaflet-oldie .leaflet-popup-tip { border: 1px solid #999; } /* div icon */ .leaflet-div-icon { background: #fff; border: 1px solid #666; } /* Tooltip */ /* Base styles for the element that has a tooltip */ .leaflet-tooltip { position: absolute; padding: 6px; background-color: #fff; border: 1px solid #fff; border-radius: 3px; color: #222; white-space: nowrap; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,0.4); } .leaflet-tooltip.leaflet-clickable { cursor: pointer; pointer-events: auto; } .leaflet-tooltip-top:before, .leaflet-tooltip-bottom:before, .leaflet-tooltip-left:before, .leaflet-tooltip-right:before { position: absolute; pointer-events: none; border: 6px solid transparent; background: transparent; content: ""; } /* Directions */ .leaflet-tooltip-bottom { margin-top: 6px; } .leaflet-tooltip-top { margin-top: -6px; } .leaflet-tooltip-bottom:before, .leaflet-tooltip-top:before { left: 50%; margin-left: -6px; } .leaflet-tooltip-top:before { bottom: 0; margin-bottom: -12px; border-top-color: #fff; } .leaflet-tooltip-bottom:before { top: 0; margin-top: -12px; margin-left: -6px; border-bottom-color: #fff; } .leaflet-tooltip-left { margin-left: -6px; } .leaflet-tooltip-right { margin-left: 6px; } .leaflet-tooltip-left:before, .leaflet-tooltip-right:before { top: 50%; margin-top: -6px; } .leaflet-tooltip-left:before { right: 0; margin-right: -12px; border-left-color: #fff; } .leaflet-tooltip-right:before { left: 0; margin-left: -12px; border-right-color: #fff; } /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } html, body { width : 100%; height : 100%; } .map-container { width : 100%; height : 100%; } <link href="https://unpkg.com/leaflet#1.3.4/dist/leaflet.css" rel="stylesheet"/> <script src="https://unpkg.com/leaflet#1.3.4/dist/leaflet.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://unpkg.com/leaflet.gridlayer.googlemutant#latest/Leaflet.GoogleMutant.js"></script> <div class="map-container" id="mapid"></div> <ul class="plot"> <li class="markers" data-lattitude="-40.99497" data-longitude="174.50808">Text 1</li> <li class="markers" data-lattitude="-41.30269" data-longitude="173.63696">Text 2</li> <li class="markers" data-lattitude="-41.49413" data-longitude="173.5421">Text 3</li> <li class="markers" data-lattitude="-40.98585" data-longitude="174.50659">Text 4</li> <li class="markers" data-lattitude="-40.93163" data-longitude="173.81726">Text 5</li> </ul>
The problem is in this line: plot.push( $(this).text(), $(this).data('lattitude'), $(this).data('longitude') ); You're pushing three items to the plot array, resulting in the plot array looking something like this: ["Text 1", -40.99497, 174.50808, "Text 2", -41.30269, 173.63696 Later, when you try to iterate over the array: for (var i = 0; i < plot.length; i++) { marker = new L.marker([plot[i][1], plot[i][2]]).bindPopup(plot[i][0], { You're accessing the second and third index of the string (the first element in plot), not the second and third index of an array (resulting in the e and x you see, which came from text). Instead, push an array of those three items to plot: plot.push([ $(this).text(), $(this).data('lattitude'), $(this).data('longitude') ]); var map = L.map('mapid', { fullscreenControl: { pseudoFullscreen: false // if true, fullscreen to page width and height }, }).setView([30.539255791073, 58.383450508118], 5); map.createPane('labels'); map.getPane('labels').style.zIndex = 650; map.getPane('labels').style.pointerEvents = 'none'; var positron = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { noWrap: true, maxZoom: 10 }).addTo(map); var positronLabels = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', { pane: 'labels', noWrap: true, maxZoom: 3 }).addTo(map); var southWest = L.latLng(-89.98155760646617, -180), northEast = L.latLng(89.99346179538875, 180), bounds = L.latLngBounds(southWest, northEast); map.setMaxBounds(bounds); map.on('drag', function() { map.panInsideBounds(bounds, { animate: false }); }); var plot = []; $('.plot > .markers').each(function() { plot.push([$(this).text(), $(this).data('lattitude'), $(this).data('longitude')]); }); console.log(plot); for (var i = 0; i < plot.length; i++) { marker = new L.marker([plot[i][1], plot[i][2]]).bindPopup(plot[i][0], { autoClose: false }).addTo(map).openPopup(); } /* required styles */ .leaflet-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-tile-container, .leaflet-pane>svg, .leaflet-pane>canvas, .leaflet-zoom-box, .leaflet-image-layer, .leaflet-layer { position: absolute; left: 0; top: 0; } .leaflet-container { overflow: hidden; } .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow { -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-user-drag: none; } /* Safari renders non-retina tile on retina better with this, but Chrome is worse */ .leaflet-safari .leaflet-tile { image-rendering: -webkit-optimize-contrast; } /* hack that prevents hw layers "stretching" when loading new tiles */ .leaflet-safari .leaflet-tile-container { width: 1600px; height: 1600px; -webkit-transform-origin: 0 0; } .leaflet-marker-icon, .leaflet-marker-shadow { display: block; } /* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ /* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ .leaflet-container .leaflet-overlay-pane svg, .leaflet-container .leaflet-marker-pane img, .leaflet-container .leaflet-shadow-pane img, .leaflet-container .leaflet-tile-pane img, .leaflet-container img.leaflet-image-layer, .leaflet-container .leaflet-tile { max-width: none !important; max-height: none !important; } .leaflet-container.leaflet-touch-zoom { -ms-touch-action: pan-x pan-y; touch-action: pan-x pan-y; } .leaflet-container.leaflet-touch-drag { -ms-touch-action: pinch-zoom; /* Fallback for FF which doesn't support pinch-zoom */ touch-action: none; touch-action: pinch-zoom; } .leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { -ms-touch-action: none; touch-action: none; } .leaflet-container { -webkit-tap-highlight-color: transparent; } .leaflet-container a { -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4); } .leaflet-tile { filter: inherit; visibility: hidden; } .leaflet-tile-loaded { visibility: inherit; } .leaflet-zoom-box { width: 0; height: 0; -moz-box-sizing: border-box; box-sizing: border-box; z-index: 800; } /* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ .leaflet-overlay-pane svg { -moz-user-select: none; } .leaflet-pane { z-index: 400; } .leaflet-tile-pane { z-index: 200; } .leaflet-overlay-pane { z-index: 400; } .leaflet-shadow-pane { z-index: 500; } .leaflet-marker-pane { z-index: 600; } .leaflet-tooltip-pane { z-index: 650; } .leaflet-popup-pane { z-index: 700; } .leaflet-map-pane canvas { z-index: 100; } .leaflet-map-pane svg { z-index: 200; } .leaflet-vml-shape { width: 1px; height: 1px; } .lvml { behavior: url(#default#VML); display: inline-block; position: absolute; } /* control positioning */ .leaflet-control { position: relative; z-index: 800; pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ pointer-events: auto; } .leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; } .leaflet-top { top: 0; } .leaflet-right { right: 0; } .leaflet-bottom { bottom: 0; } .leaflet-left { left: 0; } .leaflet-control { float: left; clear: both; } .leaflet-right .leaflet-control { float: right; } .leaflet-top .leaflet-control { margin-top: 10px; } .leaflet-bottom .leaflet-control { margin-bottom: 10px; } .leaflet-left .leaflet-control { margin-left: 10px; } .leaflet-right .leaflet-control { margin-right: 10px; } /* zoom and fade animations */ .leaflet-fade-anim .leaflet-tile { will-change: opacity; } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; transition: opacity 0.2s linear; } .leaflet-fade-anim .leaflet-map-pane .leaflet-popup { opacity: 1; } .leaflet-zoom-animated { -webkit-transform-origin: 0 0; -ms-transform-origin: 0 0; transform-origin: 0 0; } .leaflet-zoom-anim .leaflet-zoom-animated { will-change: transform; } .leaflet-zoom-anim .leaflet-zoom-animated { -webkit-transition: -webkit-transform 0.25s cubic-bezier(0, 0, 0.25, 1); -moz-transition: -moz-transform 0.25s cubic-bezier(0, 0, 0.25, 1); transition: transform 0.25s cubic-bezier(0, 0, 0.25, 1); } .leaflet-zoom-anim .leaflet-tile, .leaflet-pan-anim .leaflet-tile { -webkit-transition: none; -moz-transition: none; transition: none; } .leaflet-zoom-anim .leaflet-zoom-hide { visibility: hidden; } /* cursors */ .leaflet-interactive { cursor: pointer; } .leaflet-grab { cursor: -webkit-grab; cursor: -moz-grab; cursor: grab; } .leaflet-crosshair, .leaflet-crosshair .leaflet-interactive { cursor: crosshair; } .leaflet-popup-pane, .leaflet-control { cursor: auto; } .leaflet-dragging .leaflet-grab, .leaflet-dragging .leaflet-grab .leaflet-interactive, .leaflet-dragging .leaflet-marker-draggable { cursor: move; cursor: -webkit-grabbing; cursor: -moz-grabbing; cursor: grabbing; } /* marker & overlays interactivity */ .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-image-layer, .leaflet-pane>svg path, .leaflet-tile-container { pointer-events: none; } .leaflet-marker-icon.leaflet-interactive, .leaflet-image-layer.leaflet-interactive, .leaflet-pane>svg path.leaflet-interactive { pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ pointer-events: auto; } /* visual tweaks */ .leaflet-container { background: #ddd; outline: 0; } .leaflet-container a { color: #0078A8; } .leaflet-container a.leaflet-active { outline: 2px solid orange; } .leaflet-zoom-box { border: 2px dotted #38f; background: rgba(255, 255, 255, 0.5); } /* general typography */ .leaflet-container { font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } /* general toolbar styles */ .leaflet-bar { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65); border-radius: 4px; } .leaflet-bar a, .leaflet-bar a:hover { background-color: #fff; border-bottom: 1px solid #ccc; width: 26px; height: 26px; line-height: 26px; display: block; text-align: center; text-decoration: none; color: black; } .leaflet-bar a, .leaflet-control-layers-toggle { background-position: 50% 50%; background-repeat: no-repeat; display: block; } .leaflet-bar a:hover { background-color: #f4f4f4; } .leaflet-bar a:first-child { border-top-left-radius: 4px; border-top-right-radius: 4px; } .leaflet-bar a:last-child { border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-bottom: none; } .leaflet-bar a.leaflet-disabled { cursor: default; background-color: #f4f4f4; color: #bbb; } .leaflet-touch .leaflet-bar a { width: 30px; height: 30px; line-height: 30px; } .leaflet-touch .leaflet-bar a:first-child { border-top-left-radius: 2px; border-top-right-radius: 2px; } .leaflet-touch .leaflet-bar a:last-child { border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; } /* zoom control */ .leaflet-control-zoom-in, .leaflet-control-zoom-out { font: bold 18px 'Lucida Console', Monaco, monospace; text-indent: 1px; } .leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { font-size: 22px; } /* layers control */ .leaflet-control-layers { box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4); background: #fff; border-radius: 5px; } .leaflet-control-layers-toggle { background-image: url(images/layers.png); width: 36px; height: 36px; } .leaflet-retina .leaflet-control-layers-toggle { background-image: url(images/layers-2x.png); background-size: 26px 26px; } .leaflet-touch .leaflet-control-layers-toggle { width: 44px; height: 44px; } .leaflet-control-layers .leaflet-control-layers-list, .leaflet-control-layers-expanded .leaflet-control-layers-toggle { display: none; } .leaflet-control-layers-expanded .leaflet-control-layers-list { display: block; position: relative; } .leaflet-control-layers-expanded { padding: 6px 10px 6px 6px; color: #333; background: #fff; } .leaflet-control-layers-scrollbar { overflow-y: scroll; overflow-x: hidden; padding-right: 5px; } .leaflet-control-layers-selector { margin-top: 2px; position: relative; top: 1px; } .leaflet-control-layers label { display: block; } .leaflet-control-layers-separator { height: 0; border-top: 1px solid #ddd; margin: 5px -10px 5px -6px; } /* Default icon URLs */ .leaflet-default-icon-path { background-image: url(images/marker-icon.png); } /* attribution and scale controls */ .leaflet-container .leaflet-control-attribution { background: #fff; background: rgba(255, 255, 255, 0.7); margin: 0; } .leaflet-control-attribution, .leaflet-control-scale-line { padding: 0 5px; color: #333; } .leaflet-control-attribution a { text-decoration: none; } .leaflet-control-attribution a:hover { text-decoration: underline; } .leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-scale { font-size: 11px; } .leaflet-left .leaflet-control-scale { margin-left: 5px; } .leaflet-bottom .leaflet-control-scale { margin-bottom: 5px; } .leaflet-control-scale-line { border: 2px solid #777; border-top: none; line-height: 1.1; padding: 2px 5px 1px; font-size: 11px; white-space: nowrap; overflow: hidden; -moz-box-sizing: border-box; box-sizing: border-box; background: #fff; background: rgba(255, 255, 255, 0.5); } .leaflet-control-scale-line:not(:first-child) { border-top: 2px solid #777; border-bottom: none; margin-top: -2px; } .leaflet-control-scale-line:not(:first-child):not(:last-child) { border-bottom: 2px solid #777; } .leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-bar { box-shadow: none; } .leaflet-touch .leaflet-control-layers, .leaflet-touch .leaflet-bar { border: 2px solid rgba(0, 0, 0, 0.2); background-clip: padding-box; } /* popup */ .leaflet-popup { position: absolute; text-align: center; margin-bottom: 20px; } .leaflet-popup-content-wrapper { padding: 1px; text-align: left; border-radius: 12px; } .leaflet-popup-content { margin: 13px 19px; line-height: 1.4; } .leaflet-popup-content p { margin: 18px 0; } .leaflet-popup-tip-container { width: 40px; height: 20px; position: absolute; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; } .leaflet-popup-tip { width: 17px; height: 17px; padding: 1px; margin: -10px auto 0; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } .leaflet-popup-content-wrapper, .leaflet-popup-tip { background: white; color: #333; box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4); } .leaflet-container a.leaflet-popup-close-button { position: absolute; top: 0; right: 0; padding: 4px 4px 0 0; border: none; text-align: center; width: 18px; height: 14px; font: 16px/14px Tahoma, Verdana, sans-serif; color: #c3c3c3; text-decoration: none; font-weight: bold; background: transparent; } .leaflet-container a.leaflet-popup-close-button:hover { color: #999; } .leaflet-popup-scrolled { overflow: auto; border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; } .leaflet-oldie .leaflet-popup-content-wrapper { zoom: 1; } .leaflet-oldie .leaflet-popup-tip { width: 24px; margin: 0 auto; -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); } .leaflet-oldie .leaflet-popup-tip-container { margin-top: -1px; } .leaflet-oldie .leaflet-control-zoom, .leaflet-oldie .leaflet-control-layers, .leaflet-oldie .leaflet-popup-content-wrapper, .leaflet-oldie .leaflet-popup-tip { border: 1px solid #999; } /* div icon */ .leaflet-div-icon { background: #fff; border: 1px solid #666; } /* Tooltip */ /* Base styles for the element that has a tooltip */ .leaflet-tooltip { position: absolute; padding: 6px; background-color: #fff; border: 1px solid #fff; border-radius: 3px; color: #222; white-space: nowrap; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; pointer-events: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); } .leaflet-tooltip.leaflet-clickable { cursor: pointer; pointer-events: auto; } .leaflet-tooltip-top:before, .leaflet-tooltip-bottom:before, .leaflet-tooltip-left:before, .leaflet-tooltip-right:before { position: absolute; pointer-events: none; border: 6px solid transparent; background: transparent; content: ""; } /* Directions */ .leaflet-tooltip-bottom { margin-top: 6px; } .leaflet-tooltip-top { margin-top: -6px; } .leaflet-tooltip-bottom:before, .leaflet-tooltip-top:before { left: 50%; margin-left: -6px; } .leaflet-tooltip-top:before { bottom: 0; margin-bottom: -12px; border-top-color: #fff; } .leaflet-tooltip-bottom:before { top: 0; margin-top: -12px; margin-left: -6px; border-bottom-color: #fff; } .leaflet-tooltip-left { margin-left: -6px; } .leaflet-tooltip-right { margin-left: 6px; } .leaflet-tooltip-left:before, .leaflet-tooltip-right:before { top: 50%; margin-top: -6px; } .leaflet-tooltip-left:before { right: 0; margin-right: -12px; border-left-color: #fff; } .leaflet-tooltip-right:before { left: 0; margin-left: -12px; border-right-color: #fff; } /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } html, body { width: 100%; height: 100%; } .map-container { width: 100%; height: 100%; } <link href="https://unpkg.com/leaflet#1.3.4/dist/leaflet.css" rel="stylesheet" /> <script src="https://unpkg.com/leaflet#1.3.4/dist/leaflet.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://unpkg.com/leaflet.gridlayer.googlemutant#latest/Leaflet.GoogleMutant.js"></script> <div class="map-container" id="mapid"></div> <ul class="plot"> <li class="markers" data-lattitude="-40.99497" data-longitude="174.50808">Text 1</li> <li class="markers" data-lattitude="-41.30269" data-longitude="173.63696">Text 2</li> <li class="markers" data-lattitude="-41.49413" data-longitude="173.5421">Text 3</li> <li class="markers" data-lattitude="-40.98585" data-longitude="174.50659">Text 4</li> <li class="markers" data-lattitude="-40.93163" data-longitude="173.81726">Text 5</li> </ul>
Add/Remove class to get a menu to display
I started programming the mobile version of my nav menu earlier. I had to rework my #serviceNav to get it to work in a mobile setting. When doing this I changed my javascript from this: /*$('#serviceClick').click( function () { $('#serviceNav').addClass('activeSol'); });*/ $('[data-pop-close]').on('click', function(e) { //var targeted_pop = $(this).attr('data-pop-close'); $('#serviceNav').removeClass('active'); $('body').css('overflow', 'auto'); e.preventDefault(); }); To this: $('#serviceClick').click(function() { var relative = $(this); if (!relative.hasClass('activeSol')) { $('.activeSol').removeClass('activeSol').next('#serviceNav').slideUp(500); relative.addClass('activeSol').next('#serviceNav').slideDown(); //$('.infoTitles:before').addClass('opened'); } else { relative.removeClass('activeSol').next('#serviceNav').slideUp(500); } return false; }); The issue that I am having now that I previously didn't with my javascript code is that now my desktop media query version of my #serviceNav is not displaying, however it does display and function in the mobile setting. The trigger for this menu is the menu item called "Solutions". You can see that in a media query over 640px that nothing happens, but 640px or less it applies the fadeDown function. Does anyone see why this is not working for the larger version media query? Here is a jsfiddle Full code: $('#mobile-button').on('click', function () { $('#nav-pop').addClass('active'); $('html').addClass('is-navOpen'); }); /*$('#serviceClick').click( function () { $('#serviceNav').addClass('activeSol'); });*/ $('#serviceClick').click(function() { var relative = $(this); if (!relative.hasClass('activeSol')) { $('.activeSol').removeClass('activeSol').next('#serviceNav').slideUp(500); relative.addClass('activeSol').next('#serviceNav').slideDown(); } else { relative.removeClass('activeSol').next('#serviceNav').slideUp(500); } return false; }); nav { background: #FFF; height: 70px; width: 100%; max-width: 100%; box-shadow: 0px 6px 15px -4px rgba(0,0,0,0.12); position: fixed; top: 0; z-index: 999; box-sizing: border-box; } #nav-logo { float: left; height: 100%; width: auto; display: block; position: relative; margin-left: 5%; } #nav-logo img { height: 80%; width: auto; position: absolute; top: 50%; transform: translateY(-50%);-webkit-transform: translateY(-50%); } #mobile-button { background-image: url("https://s3.us-east-2.amazonaws.com/mbkitsystems/menu.svg"); background-size: 30px 30px; float: right; width: 30px; height: 30px; margin-right: 5%; margin-top: 15px; cursor: pointer; display: none; transition: ease 0.3s;-webkit-transition: ease 0.3s; } #mobile-button:hover { transition: ease 0.3s;-webkit-transition: ease 0.3s; } #nav-pop { float: right; display: block; margin-right: 5%; margin-top: 25px; transition: ease 0.5s;-webkit-transition: ease 0.5s; } #nav-pop.active { opacity: 1; background: rgba(0,0,0,0.8); background: #2f2f2f; right: 0; margin-top: 0; margin-right: 0; z-index: 999999; transition: ease 0.6s;-webkit-transition: ease 0.6s; transform: translateX(0);-webkit-transform: translateX(0); box-shadow: -9px 0px 9px 1px rgba(0,0,0,.2); } #nav-list li { display: inline-block; margin: 0 17px; vertical-align: top; } #nav-list li:first-child { margin-left: 0px; } #nav-list li:last-child { margin-right: 0px; } #nav-list li a, #serviceClick { text-decoration: none; font-family: 'Muli', sans-serif; font-size: .9rem; color: #747678; letter-spacing: 1px; vertical-align: top; transition: all .3s;-webkit-transition: all .3s; cursor: pointer; } #nav-list li a:after, #serviceClick:after { content: ''; display: block; width: 0; margin-top: 6px; background: #b82222; height: 2px; transition: width .3s; } #nav-list li a:hover, #serviceClick:hover { color: #4b4b4b; transition: all .3s;-webkit-transition: all .3s; } #nav-list li a:hover:after, #serviceClick:hover:after { width: 100%; transition: width .3s; } #nav-list li a.navInverse { padding: 10px 12px; border-radius: 2px; box-sizing: border-box; font-family: 'Muli', sans-serif; font-size: 1.2rem; color: #FFF; border: 1px solid #b82222; background: linear-gradient(to right bottom, #b82222, #a51e1e); text-transform: uppercase; text-decoration: none; cursor: pointer; } #nav-list li a.navInverse:hover { background: #b82222; background: #FFF; color: #b82222; /*transition: all 0s;-webkit-transition: all 0s;*/ } #nav-list li a.navInverse:after { content: ''; display: none; width: 0px; height: 0px; transition: none; } #nav-pop-close { display: none; } #nav-pop-close, #close-panel { position: relative; top: 3%; left: 90%; background-image: url("https://s3.us-east-2.amazonaws.com/mbkitsystems/icon_close.png"); background-size: 30px 30px; background-repeat: no-repeat; height: 30px; width: 30px; cursor: pointer; } /*- Service NAV -*/ #serviceNav { width: 100%; top: -40vh; left: 0; z-index: -1; position: fixed; background-color: rgba(0,0,0,0); height: 40vh; transition: all .4s; padding: 20px 0; } #serviceNav.activeSol { top: 0; width: 100%; background-color: rgba(0,0,0,.9); z-index: 99999; height: 40vh; } .popup-close { position: absolute; right: 12px; top: 12px; width: 32px; height: auto; } #serviceNavInner { margin: 0 5%; height: 100%; position: relative; } /*--- Block 1 ---*/ #serviceNavBlock1 { width: 33%; height: 100%; border-right: 1px solid rgba(255,255,255,.5); position: relative; } #serviceNavBlock1Wrap { width: 80%; text-align: left; } /*--- Block 2 ---*/ #serviceNavBlock2 { width: 66.6%; height: 100%; margin: 10px auto; position: relative; } .servNavItemWrap { display: inline-block; vertical-align: top; width: 25%; margin-bottom: 50px; text-align: center; cursor: pointer; -webkit-backface-visibility: hidden; } .servNavItemWrap img { width: 75px; height: 75px; -webkit-transition: all 0.25s;transition: all 0.25s; } .servNavItemWrap:hover img { -webkit-transition: all 0.25s;transition: all 0.25s; -webkit-transform: scale(1.1);transform: scale(1.1); -webkit-backface-visibility: hidden; } .servNavItemWrap a { text-decoration: none; outline: none; box-sizing: border-box; } .servNavItemTitle { margin-top: 5px; -webkit-transition: all 0.25s;transition: all 0.25s; } .servNavItemWrap:hover .servNavItemTitle { color: #FFF; -webkit-transition: all 0.25s;transition: all 0.25s; } /*---------------------------------------------- MEDIA QUERY 640 --------------------------------------------*/ #media screen and (max-width:640px) { #mobile-button { display: block; } #nav-pop { float: none; opacity: 0; position: fixed; margin-top: 0; width: 75%; right: -100%; height: 100vh; transform: translateX(100%);-webkit-transform: translateX(100%); } #nav-pop-close { display: block; background-size: 20px 20px; height: 20px; width: 20px; } #nav-list { margin-top: 20px; } #nav-list li { display: block; position: relative; width: 100%; margin: 0; padding: 20px 10%; background: linear-gradient(to bottom right, #151515, #2f2f2f); background: #2f2f2f; text-align: left; cursor: pointer; border-bottom: .3px solid #FFF; } #quoteButton { position: absolute; width: 100%; bottom: 0; left: 0; } #nav-list li:hover #quoteButton { background: #2f2f2f; } #nav-list li:hover, #nav-list li:active { background: #000; } #nav-list li:first-child { margin-left: 0; } #nav-list li:last-child { margin: 20px auto; text-align: center; border-bottom: none; background: #2f2f2f; padding: 20px 0; } #nav-list li a, #serviceClick { font-family: 'Nunito', sans-serif; font-size: .8rem; color: #FFF; letter-spacing: .3rem; } #nav-list li a:after, #serviceClick:after { display: none; } #nav-list li a:hover, #serviceClick:hover { color: #FFF; } #nav-list li a:hover:after, #serviceClick:hover:after { width: 0%; } /*- Service NAV -*/ #serviceNav { width: 100%; z-index: 1; position: relative; background-color: rgba(0,0,0,0); height: 200px; transition: all .4s; padding: 10px 0; display: none; top: 0; } #serviceNav.activeSol { background-color: #000; z-index: 9999999; height: auto; min-height: 20%; top: 0; border-bottom: .01em solid #FFF; } .popup-close { display: none; } #serviceNavInner { margin: 0 2.5%; } /*--- Block 1 ---*/ #serviceNavBlock1 { width: 100%; height: 50px; border-right: none; display: block; position: relative; } #serviceNavBlock1Wrap { width: 100%; text-align: center; } #navOverviewT, #navOverviewP { display: none; } #solOverviewB { font-size: .7rem; } /*--- Block 2 ---*/ #serviceNavBlock2 { width: 100%; height: 100%; margin: 10px auto; display: block; } .servNavItemWrap { display: inline-block; width: 25%; margin-bottom: 15px; } .servNavItemWrap img { width: 30px; height: 30px; } .servNavItemTitle { margin-top: 5px; font-size: .5rem; } } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <nav> <div id="nav-logo"> </div> <div id="mobile-button"><img src="" class="hidden" alt=""></div> <div id="nav-pop"> <div id="nav-pop-close"></div> <ul id="nav-list"> <li>ABOUT</li> <li id="serviceClick">SOLUTIONS</li> <div id="serviceNav"> <div id="serviceNavInner"> <div id="serviceNavBlock1" class="iblock"> <button class="buttonInv2" id="solOverviewB">Solutions Overview</button> </div><div id="serviceNavBlock2" class="iblock"> </div> </div> </div> <li>LEARN</li> <li>CONTACT</li> <li>REQUEST QUOTE</li> </ul> </div> </nav>
There is a lot going on here and frankly, it's hard to decipher but I think "Nothing happens" is relative. When inspecting the element in dev console you can see the Javascript styling is being added appropriately. So something is happening, it's simply happening off screen because you've told it to. I think the culprit here, is the >640px positioning of your #serviceNav element is maintained at top: -40vh; That's a lot. When removing this value the button displays as follows: Note: you will have to change some other things around as this displays it on page load. But you get the idea
onclick for closing cookie bar
i'm developing an app that should show a cookie bar and if the user click on the "X" it should to close, i've thinked to do it with the onclick attribute but it is ignored. This is my code: console.log("Ready !"); var close = function () { console.log("close"); } .cookie-bar { position: fixed; width: 100%; top: 0; right: 0; left: 0; height: 30px; text-align: center; line-height: 30px; background-color: #800000; color: white; font-size: 14px; font-family: "Lato", sans-serif; font-weight: 100; transition: .8s; animation: slideIn .8s; animation-delay: .8s; .message { white-space: nowrap; text-shadow: 0 1px 0 darken(red, 10%); #media (max-width: 767px){ display: none; } } .mobile { display: none; #media (max-width: 767px){ display: inline-block; } } } #keyframes slideIn { 0% { transform: translateY(-50px); } 100% { transform: translateY(0); } } .close-cb { border: none; color: white; background: darken(red, 20%); position: absolute; display: inline-block; right: 10px; top: 0; cursor: pointer; border-radius: 3px; box-shadow: inset 0 0 3px 0 rgba(0,0,0,.2); line-height: 30px; height: 30px; width: 30px; font-size: 16px; font-weight: bold; &:hover { background: darken(red, 10%); } } .checkbox-cb { display: none; &:checked + .cookie-bar { transform: translateY(-50px); } } <input class="checkbox-cb" id="checkbox-cb" type="checkbox" onclick="close()"/> <div class="cookie-bar" id="cookie"> <span class="message">Questo sito utilizza i cookies</span> <label for="checkbox-cb" class="close-cb" >x</a> </div> Can i solve it? Thank's