I'm trying to have a div on top of an image and inside that div to have a border or another div that is transparent so you can see the image below.
.image {
background-image: url(https://picsum.photos/id/10/2500/1667);
background-size: cover;
background-repeat: no-repeat;
height: 400px;
width: 100%;
}
.floater {
width: 400px;
height: 100px;
background: blue;
}
.title,
.description {
padding: 10px
}
.transparent-through {
border-bottom: 4px solid black;
width: 90%;
margin: auto;
}
<div class="image">
<div class="floater">
<div class="title">
My Title
</div>
<div class="transparent-through"></div>
<div class="description">
Short Description
</div>
</div>
</div>
I am trying to make the back "transparent-through" div transparent so you can see the image underneath the parent div.
A trik could be to draw the background-color from a shadow from your border element.(see css comments)
Create the blue background as a shadow of the transparent-through element.
Set overflow hidden on the floater to keep it from expanding outwards
You can use multiple background using
linear-gradient
to create the transparent part without the need of an extra element:Here is a more ticky idea using
clip-path
:Another one using inset box-shadow:
You can also consider pseudo-element with borders:
make the parent div position:relative and z-index:0 and make the child div position:absolute and z-index:10
this is an example follow this example you can do it .