2016-10-02 5 views
-1

ナビゲーションバーにカーソルを置くたびに、ドロップダウンメニューが作成されますが、マップによってブロックされ、スクリプトタグで作成されます。ナビゲーションバーがJavaScriptマップによってブロックされています。それを修正するには?

はここにそれがどのように見えるかです:

// JavaScript Document 
 
//This will make the navigation bar responsive. 
 
function myFunction() { 
 
    var x = document.getElementById("myTopnav"); 
 
    if (x.className === "topnav") { 
 
     x.className += " responsive"; 
 
    } else { 
 
     x.className = "topnav"; 
 
    } 
 
}
@charset "utf-8"; 
 
/* CSS Document */ 
 

 
h1 { 
 
\t margin-top: 2.2em; 
 
\t margin-bottom: 2.2em; 
 
\t width:100%; 
 
\t font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; 
 
\t font-size: 5vmin; 
 
\t color: white; 
 
\t text-align:center; 
 
\t font-weight: 300; 
 
} 
 
.auto-style1{ 
 
\t left: 25%; 
 
\t right: 25%; 
 
} 
 

 
#map { 
 
     height: 200px; 
 
     width: 50%; 
 
} 
 

 
.text{ 
 
\t width:100%; 
 
\t display: inline-block; 
 
\t text-align: center; 
 
} 
 

 
body {margin:0;} 
 

 
/*This will style the navigation bar container*/ 
 
ul.topnav { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: visible; 
 
    top: 0; 
 
    position:fixed; 
 
    width: 100%; 
 
    background-color: rgba(0,0,0,0.75); 
 
    text-align:center; 
 
} 
 

 
ul.topnav li {float: left;} 
 

 
/*This will style the items in navigation bar*/ 
 
ul.topnav li a, .dropbtn { 
 
    display: block; 
 
    color: #FFF; 
 
    text-align: center; 
 
    padding: 14px 16px; 
 
    text-decoration: none; 
 
    transition: 0.3s; 
 
    font-size: 13.75px; 
 
    font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; 
 
    font-weight:bold; 
 
} 
 

 
ul.topnav li a:hover, .dropdown:hover .dropbtn {background-color: #F00;} 
 

 
ul.topnav li.dropdown { 
 
    display: inline-block; 
 
    position: relative; 
 
} 
 

 
/*This will style the dropdown container*/ 
 
ul.topnav .dropdown-content{ 
 
    display:none; 
 
    position: absolute; 
 
    background-color: #000; 
 
    width: 100%; 
 
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); 
 
    text-align:center; 
 
    left: 0; 
 
} 
 

 
/*This will style the dropdown items*/ 
 
ul.topnav .dropdown-content a{ 
 
    color: #FFF; 
 
    padding: 12px 16px; 
 
    text-decoration: none; 
 
    display: block; 
 
    text-align: left; 
 
    font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; 
 
} 
 
ul.topnav .dropdown-content a:hover { 
 
    background-color: #999; 
 
} 
 

 
ul.topnav .dropdown:hover .dropdown-content {display: block;} 
 

 
ul.topnav li.icon {display: none;} 
 

 
@media screen and (max-width:680px) { /* Allow responsive navigation bar */ 
 
    ul.topnav li:not(:first-child) {display: none;} 
 
    ul.topnav li.icon { 
 
    float: right; 
 
    display: inline-block; 
 
    } 
 
} 
 

 
@media screen and (max-width:680px) { 
 
    ul.topnav.responsive {position: relative;} 
 
    ul.topnav.responsive li.icon { 
 
    position: absolute; 
 
    right: 0; 
 
    top: 0; 
 
    } 
 
    ul.topnav.responsive li { 
 
    float: none; 
 
    display: inline; 
 
    } 
 
    ul.topnav.responsive li a { 
 
    display: block; 
 
    text-align: left; 
 
    } 
 

 
    ul.topnav.responsive .dropdown-content{ 
 
    width: auto; 
 
    min-width: 160px; 
 
    left: 0; 
 
    } 
 

 
    ul.topnav li.dropdown{ 
 
    position: static; 
 
    } 
 
} 
 

 
.topnav li { 
 
    width: 20%; 
 
    margin: 0; 
 
    padding:0; 
 
} 
 

 
/*Footer CSS*/ 
 

 
body{ 
 
    padding: 0; 
 
    display: flex; 
 
    min-height: 100vh; 
 
    flex-wrap: wrap; 
 
} 
 

 
.wrapper{ 
 
    padding:20px; 
 
    height:auto; 
 
} 
 

 
footer{ 
 
    background-color:#333; 
 
    color: #FFF; 
 
    font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; 
 
    font-weight:bold; 
 
    align-self: flex-end; 
 
    line-height: 3; 
 
    text-align: center; 
 
    width: 100%; 
 
} 
 

 
footer img{ 
 
    width:42px; 
 
    height: 42px; 
 
    margin: 0 1em; 
 
} 
 

 
hr{ 
 
    width:100%; 
 
} 
 

 
footer p{white-space:pre; 
 
font-size: 3vmin;} /* Change. Please apply to other footers. */
<!doctype html> 
 
<html class=""> 
 
<head> 
 

 
<meta charset="utf-8"> 
 

 
<title>Contact Us</title> 
 

 
<link href="_css/headfoot.css" rel="stylesheet" type="text/css"> 
 
<link href="_css/SPcontent.css" rel="stylesheet" type="text/css"> 
 

 
<style type="text/css"> 
 
body { 
 
\t background-image: url(http://hitcolors.com/wp-content/uploads/2016/08/Green-1.jpg); 
 
} 
 
</style> 
 

 
<script src="_script/headfoot.js"></script> 
 
</head> 
 

 
<body> 
 

 
<ul class="topnav" id="myTopnav"> 
 
    <li><a class="active" href="#home">HOME</a></li> 
 
    <li class="dropdown"> 
 
    <a href="#" class="dropbtn">MENU</a> 
 
    <div class="dropdown-content"> 
 
     <a href="#">Appetizer</a> 
 
     <a href="#">Main Course</a> 
 
     <a href="#">Dessert</a> 
 
     <a href="#">Soup</a> 
 
     <a href="#">Drinks</a> 
 
     <a href="#">Side Snacks</a> 
 
    </div> 
 
    </li> 
 
    <li><a href="#aboutus">ABOUT US</a></li> 
 
    <li class="dropdown"> <a href="#" class="dropbtn">PROMOTIONS</a> 
 
    <div class="dropdown-content"> <a href="#">Breakfast</a> <a href="#">Lunch</a> <a href="#">Dinner</a> </div> 
 
    </li> 
 
    <li><a href="#contactus">CONTACT US</a></li> 
 
    <li class="icon"> 
 
    <a href="javascript:void(0);" style="font-size:15px;" onclick="myFunction()"></a> 
 
    </li> 
 
</ul> 
 

 
<h1> 
 
\t <strong><b>Contact Us</b></strong> 
 
</h1> 
 

 
<div id="map" class="auto-style1"> 
 
    <script> 
 
     function initMap() { 
 
     var uluru = {lat: 3.9414186, lng: 108.3774456}; 
 
     var map = new google.maps.Map(document.getElementById('map'), { 
 
      zoom: 6, 
 
      center: uluru 
 
     }); 
 
     var marker = new google.maps.Marker({ 
 
      position: uluru, 
 
      map: map 
 
     }); 
 
     } 
 
    </script> 
 
    
 
    <script async defer 
 
     src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAgtkYIVZT6nPYk_xCl-2f50M3YWjNkUJM&callback=initMap"> 
 
    </script> 
 
</div> 
 

 
<div class="text"> 
 
    \t <p>Address : 24,Jln Bunga Emas,43841 Syurga,Frankestain,Mars.</p> 
 
    <p>Telephone Line : 03-87876666</p> 
 
    <p>Email : [email protected]</p> 
 
</div> 
 
    
 
<footer> 
 
\t <div class="wrapper"> 
 
    \t \t <img src="Social%20Media%20Icons/facebook-icon.png" alt="Facebook"/> 
 
    \t \t <img src="Social%20Media%20Icons/icon-twitter.png" alt="Twitter"/> 
 
    \t \t <img src="Social%20Media%20Icons/YouTube-icon-full_color.png" alt="YouTube"/> 
 
    \t \t <img src="Social%20Media%20Icons/original_instagram-circle-icon.png" alt="Instagram"/> 
 
    \t \t <img src="Social%20Media%20Icons/tumblr-logo-icon-8.png" alt="Tumblr"/> 
 
    \t \t <img src="Social%20Media%20Icons/google-plus-icon.png" alt="GooglePlus"/> 
 
    \t \t <hr> 
 
    \t \t <p>S T A Y  C O N N E C T E D</p> 
 
\t </div> 
 
</footer> 
 
</body> 
 
</html>

私は何を達成したいことは前にドロップダウンメニューを持参し、背面にマップを持っています。

答えて

1

z-インデックスの完璧な使用例です。詳細については、https://developer.mozilla.org/en-US/docs/Web/CSS/z-indexを参照してください。

本質的に、z-インデックスが大きいほど、スクリーンに「近い」ことは、より小さなz-インデックスを有する他のエレメントよりも大きい。あなたの場合はz-index: 2;に、マップはz-index:1;に設定してください。

関連する問題