Hi guys I’m wondering how to make this in HTML and CSS. I know the obvious way is to make a triangular shape image in the bottom but it feels wrong. Is it possible to do it in HTML and CSS?
Edit: This is a Photoshop Design Mockup and I already said I have one solution but it feels wrong just wanted to know if somebody has another possible solution.
3
Answers
I can’t explain this at all without drawing it for you. Here is how you do it maybe someone else can fill in the blanks.
Instead of thinking about how to get a background image inside of the triangle make your background image hang lower than you need it to and put two black triangles on the top of the row bellow the image. That way it provides the illusion that your background is hanging below, when in reality you are just hiding most of it.
I’d go with
clip-path
to achieve something like this.There’s this great tool to easily generate the
clip-path
params:https://bennettfeely.com/clippy/
@JordiNebot answer is where I think we’d like to eventually land, but
clip-path
hasn’t been completely included yet. If you want to make sure it runs well everywhere, I would do something along the lines of the following. Create two triangles built from the middle out-ward well beyond what you would expect to need, then place them in absolute position at the bottom middle of the div containing the image.It’s considerably more work, but it will work better across all platforms.