question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image container is bigger than image

See original GitHub issue

OS: macOS

React-pdf version: 1.1.1

Description: Image in portrait format (ratio < 1) with a maxWidth style are centered in a container of that width.

For example, if we have an image which is 300x400 and we style it with { maxWidth: 250, maxHeight: 250 }, then the container’s width will be larger than the image itself, like so :

capture d ecran 2019-01-08 a 10 17 30

How to replicate issue including code snippet (if applies):

<Image
  style={{
    maxWidth: 250,
    maxHeight: 250,
  }}
  src={url}
/>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
maxaggedoncommented, Feb 19, 2019

Hey @diegomura ! It took me a lot of time to get back to you on this, sorry. It works fine with alignItems: "flex-start". Thanks again !

1reaction
diegomuracommented, Jan 19, 2019

Btw, this is the snippet that produced that image:

<PDFViewer style={{ flex: 1 }}>
  <Document>
    <Page style={{ padding: 50, alignItems: 'flex-start' }}>
      <Image src="/test.jpg" style={{ maxHeight: 100, maxWidth: 100  }} debug />
      <Image src="/test2.jpg" style={{ maxHeight: 100, maxWidth: 100  }} debug />
    </Page>
  </Document>
</PDFViewer>

My apologizes if I wasn’t clear enough about the root of this issue. Yoga can be sometimes cryptic to understand 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

div container larger than image inside - css - Stack Overflow
inside the wrapper there is a menu (the little red thing is part of that menu), then there is a div (id=container) whos...
Read more >
Images Larger than Container CSS - DEV Community ‍ ‍
This will center the image inside of a element when the elements height and/or width is smaller than the image.
Read more >
How to break an image out of its parent container with CSS
This trick comes courtesy of CSS expert Una Kravets. A simple utility class, .full-width , will break the image out of it's parent...
Read more >
Sizing items in CSS - Learn web development | MDN
Images should be appropriately sized to be no larger than they need to be for the largest size they are displayed in the...
Read more >
How to Auto-resize an Image to Fit into a DIV Container using ...
You can simply use the CSS max-width property to auto-resize a large image so that it can fit into a smaller width <div>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found