this post was submitted on 14 Jul 2024
14 points (100.0% liked)

CSS

8 readers
1 users here now

founded 1 year ago
MODERATORS
 

Hi,

No matter what I try


<style>
.FlexColumn {display: flex;flex-flow: column nowrap }
</style>

<div class="FlexColumn">
	<div>X</div>
	<div>X</div>
	<div>X</div>
	<div>X</div>
	<div>X</div>
</div>
<!-- I tried many CSS trick here... -->
<div>
   <span>X</span><br><span>X</span><br><span>X</span><br><span>X</span>
</div>

I always get a vertical gap between the characters !

Any ideas ?

Thanks.

top 9 comments
sorted by: hot top controversial new old
[–] Thorry84@feddit.nl 11 points 4 months ago (1 children)

line-height is the property you are looking for. Beware fucking with line-height is usually a bad idea, as characters can extend below or above the "line" and will collide.

Also maybe look at divitis, you might be suffering from it.

[–] ExperimentalGuy@programming.dev 3 points 4 months ago

I love that word divitis

[–] unmagical@lemmy.ml 9 points 4 months ago
[–] Rusty@lemmy.ca 4 points 4 months ago

Your issue is not with css, it's with typographical https://en.wikipedia.org/wiki/Leading. You can get rid of that gap with negative margin or with line-height and but it would reduce readability.

It might look okayish with your example with just letters 'X', but if you try it with any diacritic letters (like https://en.wikipedia.org/wiki/%C3%84) , the lines would overlap and the text would be unreadable.

[–] SpongeB0B@programming.dev 3 points 4 months ago* (last edited 4 months ago)

ok I've found a work around



<div>
	<div>X</div>
	<div>X</div>
	<div>X</div>
	<div>X</div>
	<div>X</div>
</div>

But if someone have something more proper, I'm all ears.

[–] lud@lemm.ee 2 points 4 months ago* (last edited 4 months ago)

Why not just a single span or paragraph with ?

[–] aqwsedrf@lemmynsfw.com 2 points 4 months ago* (last edited 4 months ago)

maybe the line-height property is the thing you are looking for.

.FlexColumn {display: flex;flex-flow: column nowrap; line-height: 0.7 }

[–] trustnoone@lemmy.sdf.org 1 points 4 months ago

Sorry if this is a silly answer as i don't kbow css well, but have you removed the inherent styling that comes with the browser. I think you need to have a

* {magin: 0; padding: 0}

[–] gotpop@mastodon.social 1 points 4 months ago

@SpongeB0B Use text box trim it just landed in Chrome Canary https://caniuse.com/css-text-box-trim