word break

Hey everyone, I've got a tricky situation where I have my logo that has each letter in a span (because I am adding animation to each span) but at a certain screensize if the logo overflows, I want it to break at a specific index so I have something like this
4 Replies
NazCodeland
NazCodeland2y ago
<span class="logo jump"><a href="/" class="first-letter" tabindex="-1">N</a><span>a</span><span>z</span><span>C</span><span>o</span><span>d</span><span>e</span>​'&ZeroWidthSpace;'<span>l</span><span>a</span><span>n</span><span>d</span></span>
<span class="logo jump"><a href="/" class="first-letter" tabindex="-1">N</a><span>a</span><span>z</span><span>C</span><span>o</span><span>d</span><span>e</span>​'&ZeroWidthSpace;'<span>l</span><span>a</span><span>n</span><span>d</span></span>
​let me make a codepen out of this actually, it will be easier to see &ZeroWidthSpace; has no impact because all the letters break on their own https://codepen.io/bbonsaye/pen/JjBVdjy You'll have to zoom and reduce the screensize to see the logo letters break
MarkBoots
MarkBoots2y ago
best way is to make .logo a flex with flex wrap and both parts of the word in a separate element. something like this https://codepen.io/MarkBoots/pen/zYLXqKw?editors=1111 you still have to apply the animations. but now the single span items are in .logo > .part > span
NazCodeland
NazCodeland2y ago
just seeing this, that's an awesome solution just want to make sure I understand the logic, we have an outer loop and an inner loop and the i==0 && j==0 checks to see if we are at the first iteration of the outer and inner loop and if so, we are at the first letter otherwise not first letter super cool, thank you for that
MarkBoots
MarkBoots2y ago
yep correct
Want results from more Discord servers?
Add your server