收藏
回答

求解,怎样把button上的文字上下左右都居中


回答关注问题邀请回答
收藏

5 个回答

  • 2019-05-01

    1、text-center + line-height 2、display:flex; justify-content:center; align-items:center



    2019-05-01
    有用 2
    回复 3
    • ABCdeful
      ABCdeful
      2019-05-02

      text-center + line-height ,这是啥意思?

      2019-05-02
      回复
    • 爱国
      爱国
      2019-06-16

      终于搞定了,谢谢

      2019-06-16
      回复
    • 余梦欣
      余梦欣
      2021-05-08
      为何我text-center + line-height不行
      2021-05-08
      回复
  • 禾店科技
    禾店科技
    2021-05-10

    看评论,搞定了,谢谢

    2021-05-10
    有用 1
    回复
  • 袁桑
    袁桑
    2020-08-15
    button {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    2020-08-15
    有用 1
    回复 2
    • 丁力
      丁力
      2020-09-13
      可以用!
      2020-09-13
      回复
    • 文
      2021-10-15
      你这样设置一下button的高度就不行了
      2021-10-15
      回复
  • ᵈᵒⁿᵍ
    ᵈᵒⁿᵍ
    2023-07-18
    当时我设置了这个也是不行
    button{
      display: flex;
      justify-content: center;
      align-items: center;
    }
    尝试添加了将按钮的padding设置成0%,就可以了。
    padding: 0%;
    
    
    
    


    2023-07-18
    有用
    回复
  • 海玄科技
    海玄科技
    2019-05-01

    你这里用的button

    还是 view

    2019-05-01
    有用
    回复 2
    • ABCdeful
      ABCdeful
      2019-05-02

      button和view都有

      2019-05-02
      回复
    • 故里、
      故里、
      2019-11-27回复ABCdeful
      我直接设置按钮高度,再设置按钮的line-height与按钮高一样能实现
      2019-11-27
      1
      回复
登录 后发表内容