antd Tooltip 组件设置宽、高不生效及解决方案

 

一、antd Tooltip 组件设置宽度不生效

antd:3x实际上4x也可以。

默认用法:

title是要显示的文字

 <Tooltip placement="topLeft" title="Prompt Text" arrowPointAtCenter>
      <Button>Arrow points to center / 箭头指向中心</Button>
  </Tooltip>

我想要改变显示出的宽度,查找api发现使用overlayClassName(类名)overlayStyle(样式) 这两个属性就可以。

于是我直接加上overlayStyle发现不生效。通过发f12审查元素,发现确实加上了但是就是没生效。包括overlayClassName也不生效,直接加style行内属性也不生效。

 <Tooltip placement="topLeft" overlayStyle={{width:900}} title="Prompt Text" arrowPointAtCenter>
      <Button>Arrow points to center / 箭头指向中心</Button>
  </Tooltip>

 

二、解决方案 

发现ant-tooltio-inner有min-width属性和min-hight属性,所以我试了一下加上min-width竟然可以了。

1.通过overlayStyle实现

因为react要求属性必须驼峰所以要是minWidth:900。同理设置高度就是minHeight:900

 <Tooltip placement="topLeft" overlayStyle={{minWidth:900}} title="Prompt Text" arrowPointAtCenter>
      <Button>Arrow points to center / 箭头指向中心</Button>
  </Tooltip>

2. .通过overlayClassName实现

 <Tooltip placement="topLeft" overlayClassName={'aa'} title="Prompt Text" arrowPointAtCenter>
      <Button>Arrow points to center / 箭头指向中心</Button>
  </Tooltip>
.aa{
 min-width:900;
 min-height:400;
}

 

antd Tooltio API 

 

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

崽崽的谷雨

漫漫前端路,摸爬滚打

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值