Skip to content

How to scale-down images? #226

Closed Answered by falkoschindler
TutorExilius asked this question in Q&A
Discussion options

You must be logged in to vote

Let's start with a simple example:

ui.image('http://placeimg.com/640/360/tech')

This shows a 640x360 image and automatically scales it up to fill the screen. Note that internally NiceGUI is using Quasar's QImg instead of a plain HTML image. Adding the class object-scale-down does not work because of two reasons:

  1. As you noticed, the class is applied to the outermost div of the QImg element, not the img tag itself.
  2. Since the size of the container is basically unlimited, the effect of the specific object-fit value "object-scale-down" is not really visible.

Instead, you can use Quasar's QImg props to specify the fit mode:

ui.image('http://placeimg.com/640/360/tech').props('fit=scale-down')

T…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TutorExilius
Comment options

@falkoschindler
Comment options

Answer selected by rodja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants