最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to align one control to the left, and center the rest in FLET? - Stack Overflow

programmeradmin3浏览0评论

Im trying to update our website, which was created in PYTHON, with FLET library. I want to position elements on my page. I want logo to be on the left, and form in the middle of the page, absolute-like alingment

I have tried something like that:

    logo =ft.Image(
            src="example/logo.png",
            width=100,
            height=100,
            fit=ft.ImageFit.CONTAIN)

    form_row = ft.Row(
        controls=[query,submit], 
        alignment=ft.MainAxisAlignment.CENTER)
    
    main_row = ft.Row(
        controls=[logo,  ft.Container(content=form_row, alignment=ft.alignment.center)],
        alignment=ft.MainAxisAlignment.START,
        vertical_alignment=ft.CrossAxisAlignment.CENTER,

    )
    page.add(main_row)

But all elements are glued to the left side

Im trying to update our website, which was created in PYTHON, with FLET library. I want to position elements on my page. I want logo to be on the left, and form in the middle of the page, absolute-like alingment

I have tried something like that:

    logo =ft.Image(
            src="example/logo.png",
            width=100,
            height=100,
            fit=ft.ImageFit.CONTAIN)

    form_row = ft.Row(
        controls=[query,submit], 
        alignment=ft.MainAxisAlignment.CENTER)
    
    main_row = ft.Row(
        controls=[logo,  ft.Container(content=form_row, alignment=ft.alignment.center)],
        alignment=ft.MainAxisAlignment.START,
        vertical_alignment=ft.CrossAxisAlignment.CENTER,

    )
    page.add(main_row)

But all elements are glued to the left side

Share Improve this question asked Mar 27 at 11:23 Jakub WójcickiJakub Wójcicki 1 2
  • in web browser you can use DevTools to see HTML and CSS - to see if they have correct values. You can also use DevTools to test different values for CSS - to see what to change to get expected result. Frankly I would prefer to do it with pure HTML and CSS instead of flet or other modules which don't allow to control pure HTML and CSS. – furas Commented Mar 30 at 12:26
  • it would be simpler if you would create minimal working code which we could simply copy and test. – furas Commented Mar 30 at 12:27
Add a comment  | 

1 Answer 1

Reset to default 0

Look, I didn't have a great experience with Flet my project didn't even get out of paper, but I think you can't position only one left because you put this command "alignment = ft.mainaxisalignment.start" no main_row ie "master" alignment is the main_row and the others will be ignored


发布评论

评论列表(0)

  1. 暂无评论