Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to create this style in CSS. this is a image i made in photoshop and i was wondering if its even possible to make in html and css alone? or do i have to use the picture. please help, it's for a school project.

the image can be seen here: 1 — imgbb.com[^]

What I have tried:

i've already tried to look at a flexbox perspective, but i'm not sure that a flexbox is the way to procced.
Posted
Updated 11-Dec-18 3:09am
Comments
CHill60 10-Dec-18 8:43am    
I took a chance and followed your link. Unusually it wasn't blocked by our firewall, but that was probably because there was nothing to see. So I can't comment on whether a flexbox would be appropriate.
Why not post the CSS you have tried and just explain what goes wrong

1 solution

You'll need to use multiple background images - one for the image, and a linear gradient for the solid colour.
Using multiple backgrounds | MDN[^]
For example: Edit fiddle - JSFiddle[^]
CSS
.fancy-image {
    box-sizing: border-box;
    width: 800px;
    height: 300px;
    background: linear-gradient(115deg, rgba(68,68,68,0) 0%,rgba(68,68,68,0) 45%,rgba(68,68,68,1) 45%,rgba(68,68,68,1) 100%), url(https://placekitten.com/800/300) top left no-repeat;
    color: white;
    padding: 80px 15px 0 390px;
}


If you want the text to follow the slanted edge, then you'll need to use a CSS shape.
Take A New Look At CSS Shapes — Smashing Magazine[^]
For example: Edit fiddle - JSFiddle[^]
CSS
.fancy-image {
    box-sizing: border-box;
    width: 800px;
    height: 300px;
    background: linear-gradient(115deg, rgba(68,68,68,0) 0%,rgba(68,68,68,0) 45%,rgba(68,68,68,1) 45%,rgba(68,68,68,1) 100%), url(https://placekitten.com/800/300) top left no-repeat;
    color: white;
}
.fancy-image::before {
    content: "";
    display: block;
    float: left;
    width: 100%;
    height: 100%;
    shape-outside: linear-gradient(115deg, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 45%,rgba(0,0,0,0) 45%,rgba(0,0,0,0) 100%);
    shape-margin: 5px;
}
 
Share this answer
 
Comments
jaket-cp 12-Dec-18 7:34am    
nice +5, multiple backgrounds - whoever new?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900