r/csshelp • u/ShlomiRex • Mar 15 '21
How to create chrome tab like rounded edges?
Like here:
I don't want to use svg for that, because I may want to change the colors of the selected tab, and I can't deal with filters for svg for selecting 'close enough' color.
Is there a way to do it in CSS/HTML?
Notice the rounded left side and right side
EDIT 1:
I mean like this:
1
u/ForScale Mar 15 '21
Close enough?
<style>
.tab {
position: relative;
width: 128px;
height: 32px;
line-height: 32px;
text-align: center;
border: 1px solid;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-bottom-color: white;
transform: translateY(1px);
}
.content {
padding: 64px 16px;
width: 360px;
height: 236px;
border: 1px solid;
}
</style>
<div class="tab">Tab</div>
<div class="content">Content</div>1
u/ShlomiRex Mar 16 '21
No, I mean like this:
1
u/ForScale Mar 16 '21
This guy pulled it off: https://github.com/adamschwartz/chrome-tabs
1
u/ShlomiRex Mar 17 '21
Yes I know he uses SVG, I'm editing his code for my own code, my own custom project :D That's why I asked because I couldn't create dark theme for that
1
u/Blu_koolaid Mar 27 '21
I don’t know enough about pseudo elements to give you actual advice, but I know enough to know this is where you want to look. You can create a grey-colored image of the rounded section and use html pseudo elements to overlay it exactly where you want it to be.
edit nevermind i didn’t read far enough to see you found a solution, still a cool concept though, hope it helps somehow
1
u/pawanrvora Mar 16 '21
I was able to make it work using a little bit of JS. A bit hacky, but I believe it meets your objectives: https://codepen.io/pawanvora/pen/xxRemOE
Click a tab to make it active.
I have added a few custom variables at the top to make it easier for you to change the colors of the selected tab (or the wrapper container and other tabs). The rest of the CSS is written using SCSS, but it's pretty straightforward.
Hope that helps.
1
0
Mar 16 '21
[deleted]
1
u/ShlomiRex Mar 16 '21
How can I make before and after elements have this kind of curve?
If you mean after element is rounded border, than it will look like this:
0
Mar 18 '21
[deleted]
1
u/ShlomiRex Mar 20 '21
RemindMe! 8 hours
1
u/RemindMeBot Mar 20 '21
I will be messaging you in 8 hours on 2021-03-20 09:13:34 UTC to remind you of this link
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
Info Custom Your Reminders Feedback
1
u/DarkStrobeLight Mar 15 '21 edited Mar 15 '21
HTML5/css3 has attributes for round edges.
https://www.w3schools.com/css/css3_borders.asp
The alternative is to create a separate div with an image of the corner.