I have a codepen
link
the issue is I want to make active tab background like a continue of the parent background image. Also as you see the tabs shows the paret of images between gap and near border-radius which is not acceptable as well.
<div class="container">...
.container {
display: flex;
flex-flow: column;
max-width: 540px;
background-image: url("https://images.ctfassets.net/hrltx12pl8hq/5ZjPpfAhn1rZWeopnHiXb/3e1b9a709297905672a0d24eac94a873/thumb_nov22_03.jpg");
}
.tabs {
display: flex;
gap: 10px;
width: 100%;
justify-content: space-between;
/* куски image чтобы не было видно между табами */
}
.tab-item {
width: 33.33%;
background: red;
padding: 20px;
border-radius: 15px 15px 0 0;
}
.tab-item .active {
/* быть такого же цвета как и image */
}
.content {
height: 500px;
width: 500px;
padding: 20px;
}
<div class="container">
<div class="tabs">
<div class="tab-item active">one</div>
<div class="tab-item">two</div>
<div class="tab-item">three</div>
</div>
<div class="content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo cumque veniam magni earum aliquam suscipit minus natus neque ut, velit alias odio porro numquam accusantium! Assumenda autem aliquid corporis. Cupiditate.</div>
</div>
2
Answers
Your post is slightly unclear but it seems like you were wanting this:
Essentially what I did is I just put the background image on the active tab and the content and then offset the content by the height of the tab. I gave the tab an explicit height to make sure it was pixel perfect as well.
It seems like you are having a few issues with your code, that you want to fix. That means it isn’t a simple tweak of a property, but more of an issue with getting everything to work together. If you had clickable tabs, then you could manipulate :hover and :active and possibly use the property of "opacity" to achieve something you want. I think switching over to clickable radio buttons will be a good start to achieving the look you’ve described.
There’s a video on YouTube that I believe will help you get what you want.
Search for "How to Easily Create Pure CSS Tabs (No JavaScript Needed!)" the content creator is dcode. Hope this helps.