I am trying to do this in css and html:
What I got so far:
<div id="logo-container">
<img decoding="async" src="https://articlett.de/wordpress/wp-content/uploads/elementor/thumbs/Articlett_Logo_RGB_1100x245px_2021-09-18_RZ_black-q1r7rix22o6ztvjf52cf1pt1ojwen0jx1zyxtcyq8m.png" title="Articlett_Logo_RGB_1100x245px_2021-09-18_RZ_black" alt="Articlett_Logo_RGB_1100x245px_2021-09-18_RZ_black" loading="lazy">
<div id="logo-shadow">
</div>
</div>
css:
#logo-shadow {
width: 250px;
height: 50px;
transform: skew(20deg);
position: absolute;
top: 10px;
left: 10px;
padding: 5px;
background-color: green;
z-index: -1;
}
#logo-container {
position: relative;
}
fiddle: https://jsfiddle.net/hobqmxjp/
Despite not knowing how to get the right shape with css, the problem is, that I need the background rectangle to have the width according to the logo file and not a fix width/height. So it also works responsive.
How can I achieve these two things?
Also
3
Answers
The following will scale with the image. I have changed
skew
torotate
as I think this is more likely to give the desired look.You just need to modify the css using the value
fit-content
with thewidth
property of the container. This way, its size is based on the size of he biggest element which is at this point the image. Then, you can use%
values to give a width and height to your #logo-shadow. You can also use relative units if you want to. Finally, you can userotate()
to rotate your shape.Hope it will help.