How can I enable box shadow to display over an embedded Google Map iframe?

I seem to be having a bit of trouble that I just can't resolve. On my website, there is a div before and after a google map Embed (iframe). The shadow of the bottom div appears on the map's bottom section, but when I use negative z-index and position relative, the shadow appears while the map functions stop working... Is there a way to show the shadow and still retain the functionality of the map?

In summary, displaying the shadow makes all map functions unavailable (drag / zoom / etc.). The issue only pertains to the top shadow, as the bottom one shows up without any problems. Removing the z-index: -10 from the map brings back the functions but removes the shadow... Any suggestions?

Code example:

HTML

#menu-divider {
  z-index: 1;
  width: 100%;
  height: 100px;
  background-color: #000;
box-shadow: 0px 0px 12px #000;
}

#map {
position: relative;
    z-index: -10;
width: 100%;
height: 300px;
border: none;
}

footer {
  z-index: 1;
position: relative;
width: 100%;
background-color: #000;
height: 100px;
box-shadow: 0px 0px 12px #000;
}
<!doctype html>

<html lang="en-us">

<head>
<title>example</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>

<body>

<div id="menu-divider">
</div>

<iframe id="map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d11797.683090046503!2d-83.05766876093261!3d42.333551617017015!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x883b2d31a25efc0f%3A0x114c7a5b16dfbdd4!2sDowntown%2C+Detroit%2C+MI!5e0!3m2!1sen!2sus!4v1534087083348" allowfullscreen></iframe>

<footer></footer>

</body>
</html>

Answer №1

After some trial and error, I finally managed to solve the problem on my own. I had to include "position: relative" and "z-index: 10" in #menu-divider and then wrap the map in a holder.

UPDATE: I added height to match the map to the holder in order to eliminate the white space at the bottom...

Here is the revised code:

#menu-divider {
position: relative;
z-index: 10;
    width: 100%;
    height: 100px;
    background-color: #000;
box-shadow: 0px 0px 12px #000;
}

#map-holder {
position: relative;
    height:300px;
}

#map {
width: 100%;
height: 300px;
border: none;
}

footer {
  z-index: 1;
position: relative;
width: 100%;
background-color: #000;
height: 100px;
box-shadow: 0px 0px 12px #000;
}
<!doctype html>

<html lang="en-us">

<head>
<title>example</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>

<body>

<div id="menu-divider">
</div>

<div id="map-holder"><iframe id="map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d11797.683090046503!2d-83.05766876093261!3d42.333551617017015!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x883b2d31a25efc0f%3A0x114c7a5b16dfbdd4!2sDowntown%2C+Detroit%2C+MI!5e0!3m2!1sen!2sus!4v1534087083348" allowfullscreen></iframe></div>

<footer></footer>

</body>
</html>

Answer №2

Check out this code snippet:

#layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

header,
footer {
  background-color: #000;
  box-shadow: 0px 0px 12px #000;
  height: 100px;
  z-index: 10;
}

main {
  flex: 1;
}

#map {
  border: none;
  min-height: 300px;
  height: calc(100vh - 200px);
  position: relative;
  width: 100%;
}
<div id="layout">
  <header></header>
  <main>
    <iframe id="map" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d11797.683090046503!2d-83.05766876093261!3d42.333551617017015!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x883b2d31a25efc0f%3A0x114c7a5b16dfbdd4!2sDowntown%2C+Detroit%2C+MI!5e0!3m2!1sen!2sus!4v1534087083348" allowfullscreen></iframe>  
  </main>
  <footer></footer>
</div>

For a more enhanced demonstration, click here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for making a JavaFX Button transparent without reducing the hitbox size

When I create a new Button in JavaFX and make the background transparent using either myButton.setBackground(Background.EMPTY); or myButton.setStyle("-fx-background-color: transparent;"), the hitbox is reduced to just the text inside the button when trigge ...

Revamp the website's design

I am looking to revamp the color theme of my website with just a click of a button. Can someone provide me with a link to a reference website where I can get some inspiration? ...

What could be causing the HTML <DATALIST> dropdown to display next to its input rather than below it?

I have an input linked to a datalist, and it's functioning correctly. However, when I initially open the dropdown, the option list appears next to (right of) the input. After entering a few characters to narrow down the list, it then shifts below the ...

Prevent the overlap of text by controlling the positioning of a div element

Below is a simplified version of the layout I'm working with: <div style="position: relative; width:600px;"> <p>Content with unknown length, but very lengthy</p> <div>Content with unknown height</div&g ...

Guide on accessing, editing, or changing properties of a parent element while the window.print() preview screen is open

Is there a way to add a new class to the parent DIV only when the window.print() preview window is open? I've run into an issue where once the preview window opens, I'm unable to make any changes in the parent window. This seems to block all scri ...

List style image does not serve its intended purpose

I attempted to personalize my webpage by adding an image to a list, but I couldn't get the list-style image to work. You can view the page at Below is the code I used: CSS /* Fleet List */ ul#flotta li { list-style-image:url("http://ctp.serviziew ...

Absolute Positions & Flexibility: A Guide

I'm currently in the process of developing an asp.net core MVC web application with bootstrap. My goal is to create a sidebar and main content area within the layout. I've written the code below in a partial view, which is then included in _Layou ...

When applying a maximum width of 100% with automatic height, images may become cropped

I'm a beginner in learning CSS, and since my technical skills are limited, I'll try to keep things simple. Currently, I have an image taking up half of the screen with the following CSS code that I found after reading some articles: <div class ...

See-through covering over adaptable square patterns

I'm looking to create responsive square image grids, each containing 9 images. Currently, I have utilized a basic bootstrap grid layout to design these grids: div class="col-md-4"> <img class="home_images" src="#image*" style="height:25%; ...

Animating width using CSS3 with percentage values

https://i.sstatic.net/SGEQZ.gif I've implemented CSS3 animations to expand the bars, but I'm facing an issue where the percentage needs to be embedded in the @keyframes-code. The custom width is currently inserted as inline CSS in the HTML. Is ...

Issues with embedding Soundcloud in Firefox

I've been grappling with a project that requires embedding Soundcloud songs. While everything functions perfectly in Chrome, Firefox presents a gray box with the Soundcloud logo instead. After attempting to troubleshoot using Firebug, I encountered t ...

ag-Grid incorporating new style elements

For my Angular application, I have a simple requirement of adding a CSS class when a row expands or collapses to highlight the row. I attempted to use gridOptions.getRowClass following the documentation at https://www.ag-grid.com/javascript-grid-row-styles ...

What is the process for creating a dropdown menu using data from a database table?

When attempting to create a drop-down menu, I encountered an issue where the menu was appearing blank. Below is the code snippet that I used: <?php $mysqli = NEW MYSQLI('localhost', 'root', '','staff'); $resultSet ...

Issue with applying Bootstrap button style to buttons

I have been attempting to customize these buttons using my CSS, but unfortunately, they are not reflecting the desired style. Even after creating new buttons, I encountered the same issue where they did not adhere to the CSS. Upon closer inspection, I not ...

Having difficulties with DIV elements

Having some difficulty creating a webpage with divs. The site I'm working on is similar to the old Myspace, so CSS can't be used in the code. Attempting to create tables using DIV elements but facing some issues. This is what my page currently l ...

Is It Possible to Run Javascript Code Based on a Specific Screen Size?

Here is the Javascript code I'm currently using to control the mobile menu functionality on my website. It prevents content outside of the menu from scrolling when the mobile menu is open and closes the menu when an item inside it is clicked. document ...

Encasing HTML Code with JSON Information

After running my code, I noticed that the page is not receiving the JSON data as expected. Instead, it displays the following string. However, all of my web API services are successfully fetching the data. {{recipe.Name}} {{recipe.desc}} {{recipe.allergen ...

Using the ng-app directive value with HTML and CSS can sometimes cause issues and the styles may not apply

angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=mainapp&p1=Error%3A…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.4.8%2Fangular.min.js%3A19%3A463) <body ng-app=""> It was working fine unt ...

"960-css: Building a Unique Framework for Sty

Considering the 960 gs CSS framework for implementation on my website. Is there any notable company utilizing this framework for their websites? Appreciate any insights. ...

Making adjustments to text in HTML without altering the CSS or styling is proving to be challenging

When attempting to modify a h1 tag without changing the CSS, I encountered an issue. Below is the string with and without the JavaScript: String without JavaScript: https://i.sstatic.net/JWOmq.png String with JavaScript: https://i.sstatic.net/RNMur.png ...