I’m having difficulties make the concrete thing in CSS as I wish.
My goal is to create a Letter in this case the letter K and make it as big as the div container it is in.
Here is the code snippet:
I included some further code because I want to then include text next to it.
The picture added shows how I would want the K to be placed with the top and bottom just inside the container. (it may be important to add that it’s in located in a carousel). It would be important to me that the solution is responsive. I would appreciate every support.
<div class="carousel-item active">
<div class="container-fluid" style="background-color: #D65A31; height: max(40vh,30vw);">
<div class="row h-100" style="line-height: 1;">
<div class="col-4 d-flex flex-column justify-content-center">
<span style="color: #2BB673; font-size: max(40vh,30vw);display: flex; text-align: center;">K</span>
</div>
<div class="col-8 d-flex flex-column justify-content-center">
<div class="row">
<div class="col">
<p style="font-size: 7vw; z-index: 1; color: #EEEEEE;">Lorem.</p>
</div>
</div>
<div class="row">
<div class="col">
<p style="font-size: 3vw; opacity: 75%; color: #EEEEEE;">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr
</p>
</div>
</div>
</div>
</div>
</div>
</div>
I already tried adjusting the size of the letter, but it usually destroyed the "layout" I had in mind and expanded the carousels size in an unwanted way. K bordering the div as wanted
2
Answers
Instead of fighting with a font, use a png image file with the letter K "drawn" in it. You can then set
<img>
width and height to 100% to fill your containing<div>
.Essentially, what you want is the
text-box
property (longhands:text-box-trim
andtext-box-edge
) but for now only Safari supports it. (Coming soon to Chrome, and hopefully others in the not too distant future.)You would use it as
In your case you’d also need to replace the
display:flex
on the span withdisplay:block