![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2015
Device: none
|
Wrapping Text Around Images
The title more or less says it all. I've been trying to get text to wrap around the images. It works in the Sigil preview, but when I try to open the file in an epub reader, it doesn't work. What happens instead is that the image is inline with the first line of the text. The rest of the text is below the image. Help?
CSS: div.img { display: block; } img.left { float: left; display: block; margin: 0 .7em .4em .3em; } XHTML: <div class="img">
<img class="left" align="left" alt="Chemestry" src="../Images/hopesprings01.png"/>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper pulvinar odio, quis egestas sapien vestibulum quis. Vivamus pretium quis nisl vulputate pulvinar. Morbi et sodales neque, a consectetur sem. Aenean et tristique sapien. Cras a orci imperdiet, tincidunt mauris et, semper augue. Praesent gravida sem ut magna luctus fringilla. Duis quis lorem a nisl semper eleifend. Vestibulum eget nunc urna.<br /><br /> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper pulvinar odio, quis egestas sapien vestibulum quis. Vivamus pretium quis nisl vulputate pulvinar. Morbi et sodales neque, a consectetur sem. Aenean et tristique sapien. Cras a orci imperdiet, tincidunt mauris et, semper augue. Praesent gravida sem ut magna luctus fringilla. Duis quis lorem a nisl semper eleifend. Vestibulum eget nunc urna. </div> Last edited by cleocalliope; 04-30-2022 at 12:22 AM. |
![]() |
![]() |
![]() |
#2 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 315
Karma: 3196766
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
Divs are already block level elements. Your div.img isn’t doing anything a regular <div> wouldn’t. I’d try wrapping your text in <p>s, and scrapping those <br/>s. That’s likely the actual reason for your problem. Your image isn’t floating around another element, because there isn’t another element. It’s just naked text in the div.
As a side note, both rules are probably overspecific. Your files will be more manageable if you use eg. .left instead of img.left unless you are using different styles for left-floated images vs any other left-floated elements. Last edited by phillipgessert; 04-30-2022 at 01:38 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,347
Karma: 20171571
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
|
Yup...what he said.
![]() Try: Code:
CSS: div.imgleft { float: left; margin: 0 .7em .4em .3em; } XHTML: <div class="imgleft"><img alt="Chemestry" src="../Images/hopesprings01.png"/></div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper pulvinar odio, quis egestas sapien vestibulum quis. Vivamus pretium quis nisl vulputate pulvinar. Morbi et sodales neque, a consectetur sem. Aenean et tristique sapien. Cras a orci imperdiet, tincidunt mauris et, semper augue. Praesent gravida sem ut magna luctus fringilla. Duis quis lorem a nisl semper eleifend. Vestibulum eget nunc urna.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean semper pulvinar odio, quis egestas sapien vestibulum quis. Vivamus pretium quis nisl vulputate pulvinar. Morbi et sodales neque, a consectetur sem. Aenean et tristique sapien. Cras a orci imperdiet, tincidunt mauris et, semper augue. Praesent gravida sem ut magna luctus fringilla. Duis quis lorem a nisl semper eleifend. Vestibulum eget nunc urna.</p> |
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2015
Device: none
|
[QUOTE=phillipgessert;4217562our files will be more manageable if you use eg. .left instead of img.left unless you are using different styles for left-floated images vs any other left-floated elements.[/QUOTE]
I have no idea what you're talking about. What's eg? I don't remember a CSS code called eg. I had the paragraphs done with <p> but tried using the <br /> on the advice of a CSS website. |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2015
Device: none
|
I just tried the code, but it didn't work. The image is no longer inline with the first sentence of the paragraph. It's just centered above it. I'm just not sure how that CSS centered the image.
Last edited by cleocalliope; 04-30-2022 at 10:15 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,347
Karma: 20171571
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
|
eg stands for the Latin phrase exempli gratia, meaning “for example.”
Based on the little bit of code you gave here, the code provided above will work. however if you have other styling saying differently, then it may take precedence...e.g. p {clear:both} we won't know unless we can see more of your CSS sheet and the area around what you are trying to affect. The only other thing I can think of is your reader doesn't follow the styling that is included with the ePub...it uses it's own built-in styling. What reader are you testing on, and does it have a "use publisher styling" option, or somesuch? Last edited by Turtle91; 04-30-2022 at 11:10 PM. |
![]() |
![]() |
![]() |
#7 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,724
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
@Turtle91, do you have CSS code for irregular shaped images and not rectangular or square?
|
![]() |
![]() |
![]() |
#8 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,126
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Please! Not that can of worms again. I remember several discussions as far back as 2013 and none of them worked across multiple platforms reliably. AFAIR, the discussion I am remembering from 2014 was related to an L shaped image and even there cross-platform was a PITA. I even seem to remember one JSWolf participating in those discussions. One of the best solutions was (if I am remembering correctly) was on Liz Castro's Pigs, Gourds and Wikis and even that was only reliable on the then version of iBooks.
|
![]() |
![]() |
![]() |
#9 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 315
Karma: 3196766
Join Date: Oct 2015
Location: Madison, WI
Device: Kindle 5th Gen
|
Sorry. I can see how that was confusing. Please ignore my entire side note. I would recommend taking some time to learn a little more about HTML and CSS. Jon Duckett wrote a very accessible and understandable book about their relationship. And I would also recommend avoiding most online advice about using <br/>. It is a very useful tag but is often abused. It seems unsuitable here.
Last edited by phillipgessert; 05-01-2022 at 01:32 AM. |
![]() |
![]() |
![]() |
#10 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,046
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
![]() |
#11 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,126
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Perhaps take a look at the epub code snippets (html / css) thread.
|
![]() |
![]() |
![]() |
#12 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,347
Karma: 20171571
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
|
|
![]() |
![]() |
![]() |
#13 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
>eg stands for the Latin phrase exempli gratia, meaning “for example.”
It was a tragedy when Latin ceased to be a part of the college-prep curriculum. Not that the STUDENTS lost the language, but that future teachers did. |
![]() |
![]() |
![]() |
#14 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,347
Karma: 20171571
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
|
Amen!
I hear these complaints all the time from my HS Latin teacher wife!! |
![]() |
![]() |
![]() |
#15 | |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2015
Device: none
|
Quote:
Here's my full CSS: Spoiler:
Last edited by theducks; 05-08-2022 at 04:30 PM. Reason: spoilered |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Text wrapping around pictures: yes on epub, no on mobi? | kevin_y | Conversion | 13 | 10-13-2020 04:22 PM |
wrapping text in the main interface? | tracis035 | Library Management | 1 | 11-01-2016 11:33 PM |
Wrapping text around images | lof | Conversion | 10 | 11-22-2012 05:09 AM |
How to fix text wrapping from a pdf? | pitchforks | Workshop | 2 | 04-29-2012 05:53 AM |
Images and text wrapping | steveboyett | Calibre | 3 | 07-20-2010 08:26 PM |