How to make this type of border using CSS ?

No description
No description
40 Replies
ἔρως
ἔρως4w ago
what have you tried?
Jochem
Jochem4w ago
if you're just talking about the highlighted secion, where the border is cut off, you can do that like this https://codepen.io/jochemm/pen/xbZzgYJ
Jochem
Jochem4w ago
but if you're talking about the glass effect, I'm sure there's a thousand tutorials on youtube on how to achieve it. The basics are to use layered box shadows, though you can probably get away with using a background gradient in .outer and putting a few px padding on it. The same corner cutting technique works for box shadows, though
kamekameha
kamekamehaOP4w ago
yeah, i have tried using linear gradient approach + pseudo selector (before,after)
ἔρως
ἔρως4w ago
jochem's solution is what i had in mind
kamekameha
kamekamehaOP4w ago
yeah i'm trying to modify the codepen to make it work for my cases seems not working i have also prepare to export it as a background if nothing is working
kamekameha
kamekamehaOP4w ago
No description
ἔρως
ἔρως4w ago
it doesn't work with opacity
ἔρως
ἔρως4w ago
Create a responsive container with a red border and rounded corners...
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
ἔρως
ἔρως4w ago
this version works with transparent backgrounds jochem's version uses the background to hide the corners, mine uses overflow: hidden
kamekameha
kamekamehaOP4w ago
it's working
ἔρως
ἔρως4w ago
jochem's version could work too, but you would have to fake the transparency
kamekameha
kamekamehaOP4w ago
i'm wondering why the border on below is gone
No description
ἔρως
ἔρως4w ago
height you're also in the wrong boxing model https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing <-- you need the border-box value
kamekameha
kamekamehaOP4w ago
No description
kamekameha
kamekamehaOP4w ago
need to reset that first to become content-box ?
ἔρως
ἔρως4w ago
you should do it for everything, but you at least need it for the .outer
kamekameha
kamekamehaOP4w ago
ok yeah added this *, *::before, *::after { box-sizing: border-box; } owh i understand if we don't use border-box it will count the padding outside from the box
ἔρως
ἔρως4w ago
it will not count the border for the size as well
kamekameha
kamekamehaOP4w ago
hmm how to do that ?
ἔρως
ἔρως4w ago
pre-calculate the color you need or, if it is for a gradient, you just use the background color of the page instead of using transparent
kamekameha
kamekamehaOP4w ago
owh ok wait i still don't really get it, but i just got it about ur approach so yeah u use overflow hidden to hide top-right & bottom-left by intenationally make them don't use border radius so it will got cut by the overflow
ἔρως
ἔρως4w ago
yes, that's my approach jochem approach covers the corners you want to show with the background color by having a smaller border radius, the inner border extends past the outer border (since the overflow is visible by default)
kamekameha
kamekamehaOP4w ago
hmmm
kamekameha
kamekamehaOP4w ago
No description
kamekameha
kamekamehaOP4w ago
so do you mean i should make the body bg color same as the inner color ?
ἔρως
ἔρως4w ago
with jochem's version, you must with my version, you do whatever you want
kamekameha
kamekamehaOP4w ago
owh ok, yeah but i think my case need have black bg coloron body and transparent bg color in inside so i think more suitable using ur approach
ἔρως
ἔρως4w ago
i think it is the more suitable one but his solution is absolutely valid as well
kamekameha
kamekamehaOP4w ago
ok anyway sir i have a lot of question about css it seems there are other's source better than w3school css, do you have any idea/recommendation any kind of website to learn css concept ?
ἔρως
ἔρως4w ago
mdn
Jochem
Jochem4w ago
literally anything is better than w3schools
ἔρως
ἔρως4w ago
maybe not ai
Jochem
Jochem4w ago
eh, yeah, maybe though it is probably trained on both w3schools and mdn, so it has a decent shot of being better
ἔρως
ἔρως4w ago
you're right
kamekameha
kamekamehaOP4w ago
ok
Jochem
Jochem4w ago
@kamekameha please don't send random friend requests to people
kamekameha
kamekamehaOP4w ago
yeah i have more question anyway, should i ask on dm or create new help channel ?
Jochem
Jochem4w ago
you can ask by opening a new post in #help do not randomly DM people just because they've helped you before, always ask first
kamekameha
kamekamehaOP4w ago
ok2 understand

Did you find this page helpful?