I need assistance with overlaying one individual div
over another individual div
.
My code looks like this:
Here follows a simple solution 100% based on CSS. The "secret" is to use the display: inline-block
in the wrapper element. The vertical-align: bottom
in the image is a hack to overcome the 4px padding that some browsers add after the element.
Advice: if the element before the wrapper is inline they can end up nested. In this case you can "wrap the wrapper" inside a container with display: block
- usually a good and old div
.
.wrapper {
display: inline-block;
position: relative;
}
.hover {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 188, 212, 0);
transition: background-color 0.5s;
}
.hover:hover {
background-color: rgba(0, 188, 212, 0.8);
// You can tweak with other background properties too (ie: background-image)...
}
img {
vertical-align: bottom;
}