I’m struggling to recreate a designed header from a poster in html/css.
I can get it to work as per the image, but it needs to have a transparent background so the image shows through. However, the dividing border appears as soon as I make the background transparent, which is not what I want.
Is there any way around this?
Image of header with solid background
html {
min-height: 100vh;
display: grid;
place-content: center;
background: url(https://www.iwa.ie/app/themes/iwa-theme/resources/assets/img/sport/basketball/senior-league-main-hero.webp) 50% / cover;
}
.branded-header {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.brand-header-top {
display: inline-block;
border: 2px solid #fff;
border-bottom: none;
border-radius: 8px 20px 0 0;
padding: 7px 37px 0px 20px;
text-align: left;
font-size: 35px;
background: #transparent;
position: relative;
z-index: 1;
color: #fff
}
.brand-header-bottom {
display: inline-block;
border: 2px solid #fff;
border-top: 2px solid #fff;
border-radius: 0 8px 8px 8px;
padding: 16px 19px 6px 20px;
text-align: left;
font-size: 53px;
background: #transparent;
margin-top: -2px;
font-family: CentraleSans, sans-serif;
color: #fff;
line-height: 64px;
}
<div class="container">
<div class="branded-header" style="margin-top: 60px">
<div class="brand-header-top">
Wheelchair Basketball
</div>
<div class="brand-header-bottom">
Senior League 2024/2025
</div>
</div>
</div>
3
Answers
I think there are multiple ways you can achieve this layout and you are probably in a good path by now so I’m just going to give you an idea for the background image effect. The following method uses a background image, a color overlay and a blend mode to achieve a similar effect. Here’s an example:
In this case the
multiply
blend mode works because it multiplies your image with the overlay color, resulting in a darker image. This mode is particularly useful for adding color tints to images while retaining detail which I think is exactly what you’d want here.Adding the same background image with
background-attachment:fixed
to your.brand-header-top
would do the trick:I updated your code a little bit and it works exactly same as your design.