Open
dvschultz
opened this issue 11 years ago
•
14 comments
trafficstars
if an <img> is wrapped in a <figure> tag and the figure tag has left padding on it, the image inside extends outside of its wrapper. Seems like even width: 100% on the <img> doesn’t work to fix it.
figure {
width: 80%;
padding: 0 10%;
}
figure img {
width: 100%;
max-width: 100%
}
this causes the image to stick outside the figure area. works fine in every other kindle device.
—
Reply to this email directly or view it on GitHub.
@teytag the issue isn’t centering. its that the paperwhite doesn’t size the image inside its container correctly. assigning width: 100% to the should make the width 100% of its containing element. Instead, its making it 100% the width of the viewport and pushing the right side outside the figure container.
As you can see in the example blow, you do not need to give a box-sizing value fot the IMG element. This is because the IMG element is not a carrier tool.
This issue seems only to be happen, if your image is a png (24) graphics file. Did you already try to use a jpeg?
My overall devices solution is to have two div wrappers, where the inner one is styled as an inline-block, which defines the relative size of the image. The outer wrapper has an text-align: center to center the inline-block. So it is similar, but not the same.
I also made the experience, that sometimes left aligned images (png’s) are sized correctly, whereas centered or right aligned are not.
I am not quite sure about this behaviour and still confused, because the possible reasons seem nebulous to me. By the way, I tested in Kindle Previewer 2.94 with eInk Voyager.