![]() |
#1 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: May 2017
Device: None
|
How to keep a Header and svg wrapped img on the same page
I'm new to epub and my experience with html/css is minimal. So I'm not sure if what I'm trying to accomplish is best practice or possible. I'm open to hearing a better way.
I want my <h2> header to stay with an svg wrapped image. So the chapter title page will be the header(h2 tags) followed by an svg wrapped image that fills the rest of the page. Then the text starts on the next page. As of right now I get a chapter title(h2 tags) on its own page. Then the svg image on the next page. After reading most of the threads on svg I finally found code that properly centered the image(at least in the kindle previewer). Pasted in HTML page header. Code:
<style type="text/css"> @page { margin: 0.000000pt; padding: 0.000000pt; } </style> Code:
.svg_outer { display: block; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: left; } .svg_inner { display: block; text-align: center; } Code:
<div class="svg_outer"> <div class="svg_inner"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 1201 1800" preserveAspectRatio="xMidYMid meet"><image width="1201" height="1800" alt="John standing triumphantly by a flag" xlink:href="../Images/Leap1small.jpeg"/></svg> </div> </div> I'm using Sigil and I've seen some guides on building a TOC from none headers. So I'm not stuck on the h2 tags. I'm also not stuck on the svg wrapper it just seemed like the way to go. I really just want a best practice/elegant solution. |
![]() |
![]() |
![]() |
#2 |
Interested in the matter
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
You can take a look at one of my epubs (https://www.mobileread.com/forums/sh...d.php?t=268249).
The idea is to include all the text (for example the title of a chapter) in the svg wrapper, and before putting the header with its tag defined in the css as: Code:
display:none; |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: May 2017
Device: None
|
Quote:
I've tried to put the h2 tags inside the svg wrapper but I still get a page with just the Chapter Header and the full page illustration on the next page. Wouldn't the display: none; make the header disappear? |
|
![]() |
![]() |
![]() |
#4 |
Interested in the matter
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
Note the file "portada.xhtml", in this case it is a cover and the tag is <h1> (but this is the same for a cover, a chapter, etc.).
Observe the text carefully within the svg. In the file "Estilo.css" you will find that the h1 tag (in your epub should be h2) has the property: display-none. In short the header tag does not actually look, it's for the TOC. What you see is the text that is in the svg wrapper. |
![]() |
![]() |
![]() |
#5 | |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: May 2017
Device: None
|
Quote:
I understand now. Thanks for the help. This worked in firefox's epub reader but the text was missing in the Kindle previewer. I couldn't tell if the previewer was ignoring the x,y coordinates or the image was covering the text. The text was also trapped inside the image. Because the image is trying to fill the page as much as possible, there is no space at the top for the chapter title/text to sit. I'm trying to create this space for the chapter title to be preserved and have the svg wrapped image fill the rest of the available space while maintaining its aspect ratio. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,348
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
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 | |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: May 2017
Device: None
|
Quote:
HTML Code:
<body> <h2 class="hide">One Giant Leap</h2> <div class="svg_outer"> <div class="svg_inner"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 1201 1800" preserveAspectRatio="xMidYMid meet"><image width="1201" height="1800" alt="John standing triumphantly by a flag" xlink:href="../Images/Leap1small.jpeg"/> <text class="large" x="600" y="100">Chapter Title</text> </svg> </div> </div> Code:
.svg_outer { display: block; margin-bottom: 0; margin-left: 0; margin-right: 0; margin-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: center; } .svg_inner { display: block; text-align: center; } text.large { font-weight: bold; margin-top: 1em; margin-bottom: 1em; font-size: 700%; font-style: italic; text-indent: 0em; text-align: center; text-anchor: middle; } |
|
![]() |
![]() |
![]() |
#8 |
Interested in the matter
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
This is the forum for epubs, maybe you find help in the forum for kindle formats.
Last edited by jbacelar; 05-08-2017 at 05:53 PM. |
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: May 2017
Device: None
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is there a way to show chapter name as header on every page? | Dragan Tanevski | ePub | 10 | 10-28-2015 03:27 PM |
IMG inside SVG inside TD? | Kasper Hviid | Sigil | 4 | 05-25-2014 06:57 AM |
<svg> to <img> | codrutoctavian | ePub | 8 | 03-01-2012 08:54 PM |
<svg> to <img> tags conversion | codrutoctavian | Conversion | 1 | 02-15-2012 09:58 PM |
Odd and Even page Header Settings | RajeshKumar | Sony Reader | 11 | 05-18-2007 10:16 AM |