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.

Inline CSS is stretching images

See original GitHub issue

Hi, in our company we have been using your library and it is working perfectly.

However, we noticed that the inline CSS is stretching the images.

squeeze-img

We wrote the css that you need to add in order to avoid this problem.

So, instead of using this


position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;

You need to add this

    position: absolute;
    left: -10000%;
    right: -10000%;
    top: -10000%;
    bottom: -10000%;
    margin: auto auto;
    min-width: 1000%;
    min-height: 1000%;
    object-fit:cover;
    -webkit-transform: scale(.1);
    transform: scale(.1);

Then, the image looks better.

scale-img

You can see a live version of the technique here: Mipon

In case that you prefer keep using the same CSS, is it possible that we can add our own css to the img?

You can check this library as a reference: https://github.com/reactjs/react-tabs/issues/148

The logic is the same, but the library allows to customize the CSS using StyledComponents.

Thanks! have a great weekend.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
oquirozmcommented, Sep 23, 2019

@bluebill1049 sure, will do in a bit

0reactions
bluebill1049commented, Sep 23, 2019

sure @oquirozm u want to submit a PR to update readme?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline style for background image stretch - css - Stack Overflow
Inline style for background image stretch ... Within a div, I am trying to stretch a header image both horizontally (width) and vertically ......
Read more >
Inline CSS is stretching images · Issue #57 - GitHub
Hi, in our company we have been using your library and it is working perfectly. However, we noticed that the inline CSS is...
Read more >
How to Stretch a Background Image in CSS - Quackit Tutorials
To stretch a background image in HTML, use the CSS background-size property or the background shorthand property. Run. Stack editor. Unstack editor. Editor ......
Read more >
inline-size - CSS: Cascading Style Sheets - MDN Web Docs
The inline-size CSS property defines the horizontal or vertical size of an element's block, depending on its writing mode.
Read more >
HTML Background Images - W3Schools
To add a background image on an HTML element, use the HTML style attribute and ... If you want the background image to...
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