How to scale-down images? #226
-
Hello! Based on the slideshow example: https://github.com/zauberzeug/nicegui/blob/main/examples/slideshow/main.py The code below does not result to that what I expect: In HTML the adding class 'object-scale-down' lands in the div element above it, not in my Element. Is it possible that nicegui is not correctly packing the defined tailwind classes into the correct element? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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
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') This should do the trick. To show the effect more clearly, let's specify a fixed size and some background color: ui.image('http://placeimg.com/640/360/tech').props('fit=scale-down').classes('w-80 h-80 bg-blue-100') |
Beta Was this translation helpful? Give feedback.
Let's start with a simple example:
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:Instead, you can use Quasar's QImg props to specify the fit mode:
T…