![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
Shifty Dot Leader?
I just played with a book that included a dramatis personae that had a fixed number of periods as a dot leader between the character name and his description. I worked around that, but afterward, I looked for a css class to automatically fill in the gap between two pieces of text. I found some references to CSS3 supposedly having that function built in:
https://www.w3.org/TR/css-gcpm-3/#leaders but 1) haven't been able to figure it out, and 2) don't know if was actually implemented. Anway, looking around the web, I found alternative ways and tried this: Code:
.dotleaderline { /* Turns a block into a flexbox so it can be "responsive" */ display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: center; align-items: flex-end; } .dotfiller { /* Stuck between two objects in a flexbox, will fill the gap with dots */ flex-grow: 1; border-bottom: 0.1em dotted; min-width: 1.2em; } Code:
<ul class="ul_none"> <li class="dotleaderline"><span>first text</span><span class="dotfiller"/><span>last text</span></li> <li class="dotleaderline"><span>another text</span><span class="dotfiller"/><span>even more last text</span></li> </ul> The problem is that if there's a text-indent being applied to the objects, the set of dots gets shifted (left or right) by that text-indent and end up in the middle of the actual text. I haven't been able to find a way to override those text-indents and get this to work. The only thing I've found so far is simply setting that text-indent to 0. Anyone have a better idea? |
![]() |
![]() |
![]() |
#2 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,131
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Not sure of ALL the ramifications, but have you tried using a margin-left, or padding-left, on the <ul>/<li> instead of text-indent??
I also added a little padding to the right and left of the spans to have a little bit of space between the dots and the letters. Code:
<head> <title></title> <style> ul {margin:0; padding:0} li {margin:0; padding-left:2em} .dotleaderline { /* Turns a block into a flexbox so it can be "responsive" */ display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: center; align-items: flex-end; } .dotleaderline span {padding:0 .25em} .dotfiller { /* Stuck between two objects in a flexbox, will fill the gap with dots */ flex-grow: 1; border-bottom: 0.1em dotted; min-width: 0; padding:0 1.5em } </style> </head> <body> <ul class="ul_none"> <li class="dotleaderline"><span>first text</span><span class="dotfiller"/><span>last text</span></li> <li class="dotleaderline"><span>another text</span><span class="dotfiller"/><span>even more last text</span></li> </ul> </body> </html> |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
Quote:
Code:
.ul_none { /* Unordered List No Bullet */ display: block; list-style-type: none; margin-left: 1.2em; margin-right: 1.2em; padding-left: 1.5em; text-indent: -1.5em; } However, if I just bite the bullet and include a text-indent:0 in the dotleaderline class, that does fix the shifty dots (at the expense, of course, of the indent): Code:
.dotleaderline { /* Turns a block into a flexbox so it can be "responsive" */ align-items: flex-end; display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: center; text-indent: 0em; } Code:
.dotleaderline span { /* Put some space between the spanned objects in the dotleaderline */ padding-top: 0em; padding-right: 1.25em; padding-bottom: 0em; padding-left: 1.25em; } |
|
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
About using this outside of a list, it looks like I was wrong about the behavior being the same. If I use a paragraph to hold the spans, the whole line get's scrunched around. If I use a div to hold them, it looks fine.
I'm still trying to figure out what's happening there. |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,213
Karma: 4949904
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
FWIW, I use definition lists for my character summaries.
Code:
<dl> <dt>Zarvora Cybeline</dt> <dd>Highliber of Libris, the mayoral library, at 26 years old</dd> <dt>Lemorel Milderellen</dt> <dd>From Rutherglen Unitech library. Dragon Orange level at nineteen years old</dd> <dt>Vellum Drusas</dt> <dd>Deputy Overliber, Inspectorate Service</dd> </dl> Then style it in the CSS page. |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
Quote:
Probably don't need the dot leaders with <dl>, but I wonder if it's doable. EDIT: Doesn't look like it would be either desirable or doable to put dot leaders in a <dl>. The basic form would be enough. Last edited by enuddleyarbl; 09-27-2022 at 09:04 PM. |
|
![]() |
![]() |
![]() |
#7 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
|
Looks like I'll also have to add margin-top and margin-bottom set to 0 into the dotleaderline class. It appears that the default <li> has some positive spacing there and it spaces things out more.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
I Come in Peace! Take Me to Your Leader! | Ghod | Introduce Yourself | 2 | 01-28-2017 05:55 PM |
Take me to your leader!!! | Mad Genuis | Introduce Yourself | 14 | 06-13-2010 12:27 AM |
I come in peace! Take me to your leader! | Shyriath | Introduce Yourself | 10 | 02-27-2009 02:38 PM |