I am willing to add some inset box-shadow to a tag that is containing a Google Maps element. However, it seems nothing happens, probably because Google loads some other div's in the original element, hence covering the generated box-shadow.
How can I achieve this effect?
Here's the code I have:
<section id="map-container">
<figure id="map"></figure>
</section>
#map-container {
position: relative;
float: right;
width: 700px;
background-color: #F9FAFC;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
#map {
position: relative;
height: 400px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
box-shadow: 0 1px 0 0 #F6F7FB inset, 0 -1px 0 0 #E0E5E1 inset, 0 -2px 0 0 #EBEBED inset, 0 -3px 0 0 #F4F4F6 inset;
}
Thank you!
In CSS, shadows on the boxes of elements are created using the box-shadow property (if you want to add a shadow to the text itself, you need text-shadow ). The box-shadow property takes a number of values: The offset on the x-axis. The offset on the y-axis.
Inset shadows are drawn inside the border (even transparent ones), above the background, but below content. <offset-x> <offset-y> These are two <length> values to set the shadow offset. <offset-x> specifies the horizontal distance. Negative values place the shadow to the left of the element.
The map uses a grey colored overlay to show you shaded areas based both on the local terrain and on the height of nearby buildings. At the bottom of the map is a timeline control which allows you to view shadow locations for any time of the day.
That's how I did it. The following method won't overlap map controls, so you will be able to manipulate the map, i.e. drag, click, zoom, etc.
HTML:
<div class="map-container">
<div class="map"></div>
</div>
CSS:
.map-container {
position: relative;
overflow: hidden;
}
.map-container:before, .map-container:after, .map:before, .map:after {
content: '';
position: absolute;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
z-index: 1;
}
.map-container:before { top: -5px; left: 0; right: 0; height: 5px; }
.map-container:after { right: -5px; top: 0; bottom: 0; width: 5px; }
.map:before { bottom: -5px; left: 0; right: 0; height: 5px; }
.map:after { left: -5px; top: 0; bottom: 0; width: 5px; }
DEMO: http://jsfiddle.net/dkUpN/80/
UPDATE: The old solution (see 1st revision) didn't have pseudo-elements support and was compatible with old browsers. Demo is still available here: http://jsfiddle.net/dkUpN/.
I just had the same issue while trying to add an inset shadow to one side of an embedded map. I tried adding it to the map-canvas element but no shadows were visible. No idea about the reason of this behaviour, maybe is the position:absolute of some of the elements within the map.
Anyway, instead of adding other unsemantic elements to the code, I'd rather go for a pseudoelement made of a thin (5px) strip overlayed to the map:
This adds the shadow on the left side:
#map-container:before {
box-shadow: 4px 0 4px -4px rgba(0, 0, 0, 0.5) inset;
content: "";
height: 100%;
left: 0;
position: absolute;
width: 5px;
z-index: 1000;
}
demo: http://jsfiddle.net/marcoscarfagna/HSwQA/
For a right side shadow instead:
#map-container:before {
box-shadow: -4px 0 4px -4px rgba(0, 0, 0, 0.5) inset;
content: "";
height: 100%;
right: 0;
position: absolute;
width: 5px;
z-index: 1000;
}
Figured it out. Here the working CSS:
#map-container {
position: relative;
float: right;
width: 700px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
box-shadow: 0 1px 0 0 #F6F7FB inset, 0 -1px 0 0 #E0E5E1 inset, 0 -2px 0 0 #EBEBED inset, 0 -3px 0 0 #F4F4F6 inset;
}
#map {
position: relative;
height: 400px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
z-index: -1
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With