How to vertically align image in .ePub?

No Comments

Here’s a sample code to align image vertically in .ePub

Step1: Open your .ePub file in Sigil or similar software.

Step 2: Go to “Styles” folder. Add this code to your .css file.

CSS:

img.verticalCenter {

width: 100%;

max-height: 50%;

margin-top: 40%;

margin-bottom: 30%;

}

Step 3: Open your HTML file with image to be aligned vertically. Change your code as following:

HTML

<p style=”text-align: center;”>

<img alt=”index-15″ class=”verticalCenter” src=”../Images/index-15_1.jpg”/>

</p>

Note: Text-align:center will center the image horizontally.

Step 4: Add the following code to <head> tag in order to avoid the overflow:

HTML

<style type=”text/css”>

@page {padding: 0pt; margin:0pt}

body { text-align: center; padding:0pt; margin: 0pt }

p { padding:0pt; margin: 0pt }

img { padding:0pt; margin: 0pt }

</style>

Step 5: Save your .ePub file to view the changes.

Results:

Valign-1

How to give top margin in Kindle?

Unfortunately, this will not work for Kindle devices. So for Kindle, we can put some margin on top of the text, like:

.margins

{

margin-top:50%;

}

This will also give result. But margin from top will depend upon the length of target text.

Valign-2

 

This is author biographical info, that can be used to tell more about you, your iterests, background and experience. You can change it on Admin > Users > Your Profile > Biographical Info page."

About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

More from our blog

See all posts
No Comments

Recent Posts