I asked a similar question for iOS NSAttributedString but since it’s not possible with that, I am looking for a way to achieve this via HTML, CSS and javascript if needed.
I know CSS has “drop cap” using first-letter. Example: https://codepen.io/tutsplus/pen/GZxjEM
However, I need to do it for entire words and not just first-letter.
In the following picture, notice how “Strength” is the biggest and then “is not something” and “you have, rather” share the same line as “Strength”.
NOTE: My problem isn’t how to format the first word – it’s how to have 2 lines share the first line. Notice how “Strength” is the biggest and then “is not something” and “you have, rather” share the same line as “Strength”. How to make them share the same line? Similar to how drop-caps lets you have multiple lines be shared with the first letter.
I need to achieve a similar look with HTML, CSS and JS. If drop cap is not possible for this, is there any other way I can achieve this?
NOTE: Since my text will be variable, I can’t use an image/photoshop etc.
EDIT: From suggestions, CSS Flexbox might be able to achieve this. I need to figure out how to place my words in the boxes:
<div>
<div style="float: left; font-size: 4em; background-color:grey;">
STRENGTH
</div>
<div style="float: left; padding-left: 10px; background-color:yellow;">
<div>
<span style="font-size: 2em;">is not</span><span style="font-size: 1em;"> something</span>
</div>
<div>
you have, rather
</div>
</div>
</div>
<div style="clear: both; font-size: 2em;">
something that reveals itself
</div>
<div style="font-size: 4em;">
when you need it.
</div>
<div style="font-size: 1em;">
#myHASHTAG
</div>
3
Answers
Try this:
I write an example for you and try to make it like the photo u share, hope it can be usefull for you :
HTML :
css :
https://jsfiddle.net/emilvr/6o2fpf9t/1/
Here is a structure you can use, with Flexbox