![]() |
#1 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
Alignement of blocks
I need to simulate a table in that several lines are indented as the first one of the block. I thought I solved it using inline-block, yet when one of the lines is longer that needs to be split onto two display lines, the alignement disappears.
See the following image: The coloured borders are there to help identify the blocks as they are. The code uses inline-block and clear as properties for the blocks. I tried every combination possible with p, div and span, and the image was taken using a span inside a p. I don't wanna use float. I also don't want to use a table since I only have 3 or 4 cases where I need this arrangement but hundreds of references. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,633
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Why don't use a negative indent? Something like:
Code:
.negindent { margin-left: 2em; text-indent: -2.0em; } Code:
<p class="negindent">162. —How do you do?<br/>—How do you do?</p> Regards Rubén EDIT: What are you working with? Epub2? Epub3? And of course always you have the choice of using the "float: left" property for the number. Just give the class a proper height for example: Code:
.nfloat { float: left; height: 4em; background: khaki; /* remove this */ } Code:
<p><span class="nfloat">162. </span>—How do you do?<br/>—How do you do?<br/>—Please a coffe.</p> Add also a proper right margin to the floated number. Last edited by RbnJrg; 09-02-2019 at 07:48 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
I can't use a negative indent because it's variable (there are numbers of 1-2-3 digits).
I don't want to use float for it's rendered differently by various ereaders if the page ends right there, in between. Plus, again, it's width has to be dynamically computed, which I understand is possible only in epub3. Sorry, it's epub2. |
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,295
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
You can use an unordered list with a different class depending on how many digits are in the number. The borders in the CSS are just to show the box-model spacing.
The mdash is not an option as a list-item marker, so I just did a quick .png file so I could use the list-style-image property. You will want to make a different image so that it aligns vertically a little better. CSS: Code:
p {margin:0; border:1px solid green} p.spc {margin-top:2em} ul {margin:-1.2em 0 0; list-style-image:url('../Images/bar.png'); border:1px solid red} ul.one {margin-left:.6em} ul.two {margin-left:1.15em} ul.three {margin-left:1.7em} ul.four {margin-left:2.2em} Spoiler:
Unfortunately, you still won't be able to completely predict how each device will split pages. They may still split the <ul> off to the next page. Last edited by Turtle91; 09-03-2019 at 08:10 AM. |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,633
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
In combination with unordered list as Turtle91 appointed, you can also use ordered list, and not only for the problematic blocks, but for all. But if you only want to use ordered list for the problematic blocks, then do the following:
Code:
<ol start="162"> <li><p>—How do you do? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula. Praesent orci dui, pulvinar id convallis a, faucibus non mauris. Donec tellus augue, tempus sed facilisis sed, fringilla quis leo. Mauris vulputate, leo ac facilisis vulputate, enim orci interdum augue, in blandit quam turpis quis dui. Morbi dictum luctus velit nec faucibus. Cras vitae tortor purus, ut tincidunt mauris. Sed at velit nisl. Donec eu mauris tortor, interdum condimentum erat. Nam egestas turpis eget nibh laoreet pharetra. Suspendisse a sem eros, ut pulvinar enim. In sed elit eu nulla accumsan tincidunt eget sit amet ipsum. Nullam ut massa rutrum dolor placerat tempor accumsan eget purus.</p> <p>—How do you do?</p> <p>—Please a coffe.</p></li> </ol> Code:
li p { margin: 0em 0em 0em 1em; text-indent: -1em; } So the drawback for using negative indents is superated (since numbers are not involved). Last edited by RbnJrg; 09-03-2019 at 08:28 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,295
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I definitely prefer RbnJrg's use of ordered lists.
![]() RE my previous post: you could use a simple SVG instead of creating a .png SVG: Code:
<svg width="1em" height="1em" version="1.1" xmlns="http://www.w3.org/2000/svg"> <line x1=".1em" x2=".9em" y1=".6em" y2=".6em" stroke="black" stroke-width="1"/> </svg> Code:
ul {margin:-1.2em 0 0; list-style-image:url('../Images/dash.svg'); border:1px solid red} |
![]() |
![]() |
![]() |
#7 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
But then I get into the unsolvable issue of not being able to link the automatically generated number to the text it serves.
I can't belive nobody ever had this issue before. |
![]() |
![]() |
![]() |
#8 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
![]()
Sorry, for the previous answer - I haven't seen the spoiler opens into a HTML code.
This might be the answer I was looking for. Thank you. |
![]() |
![]() |
![]() |
#9 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
|
I used the ul with attribute none and the mdash as part of the text.
The margin-top of -1.2em also contributed to the trick. |
![]() |
![]() |
![]() |
#10 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,295
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I thought you wanted the mdash to be separated from the text (no overlap with the words), that's why I went with the list-style-image. As long as you are happy with it, sweet!
|
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,633
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#12 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,295
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
It was a different thread - and yes, he was referring to the auto generated number in an <ol>
|
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,633
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
![]() |
![]() |
![]() |
#14 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,295
Karma: 20171067
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Care to give an example of how to create a link on a number generated when a page is rendered?
|
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,633
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Code:
<ol> <li><a class="myN" href="../Text/Section0002.xhtml#N1">*******</a> <p>—How do you do? Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula. Praesent orci dui, pulvinar id convallis a, faucibus non mauris. Donec tellus augue, tempus sed facilisis sed, fringilla quis leo.</p> <p>—How do you do?</p> <p>—Please a coffe.</p></li> </ol> Code:
li { margin-bottom: 1em; margin-left: -0.5em; color: red; /* This is to mimic the format used by the OP */ font-weight: bold; } li p { margin: 0em 0em 0em 1em; text-indent: -1em; color: black; font-weight: normal; } a.myN { float: left; margin-left:-2em; height: 1.2em; text-decoration: none; /* Again, to mimic the format used by the OP */ } Regards Rubén |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Seriously thoughtful Zepto virus blocks my files | Luke2 | Lounge | 9 | 10-16-2016 01:51 PM |
conversion blocks the program | volopazzo | Conversion | 6 | 01-11-2015 08:54 AM |
Immutable code blocks | crutledge | Sigil | 1 | 05-10-2010 07:54 PM |
fonts as blocks in calibre | waxly | Calibre | 1 | 03-24-2010 10:42 PM |