Skip to content

Image inside a row with the right aspect ratio #3603

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

You must be logged in to vote

Hi @PoshoDev,

I see two possibilities:

  • Use QImg's "height" prop instead to set the image height, "fit=scale-down" and "position" to place it inside the occupied space:

    with ui.row(wrap=False).classes('w-full h-32 items-center border-2 border-blue-500'):
        ui.button('Button')
        ui.image('https://dummyimage.com/640x480').props(r'height=100% fit=scale-down position="0 0"')
  • Alternatively you can use ui.interactive_image, which behaves a bit more ordinarily when it comes to layout and sizing:

    with ui.row(wrap=False).classes('w-full h-32 items-center border-2 border-blue-500'):
        ui.button('Button')
        ui.interactive_image('https://dummyimage.com/640x480').classes('h-full')

In both…

Replies: 1 comment 2 replies

Comment options

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

@python-and-fiction
Comment options

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