How do you change the width and height of Twitter Bootstrap's tooltips?

后端 未结 21 1433
情歌与酒
情歌与酒 2020-12-12 13:26

I created a tooltip using Twitter Bootstrap.

The tooltip is displaying with three lines. However, I would like to display the tooltip with only one line.

How

21条回答
  •  天涯浪人
    2020-12-12 13:56

    Just override the default max-width to whatever fits your needs.

    .tooltip-inner {
      max-width: 350px;
    }
    

    When max-width doesn't work (option 1)

    If max-width does not work, you could use a set width instead. This is fine, but your tooltips will no longer resize to fit the text. If you don't like that, skip to option 2.

    .tooltip-inner {
      width: 350px;
    }
    

    Correctly dealing with small containers (option 2)

    Since Bootstrap appends the tooltip as a sibling of the target, it is constrained by the containing element. If the containing element is smaller than your max-width, then max-width won't work.

    So, when max-width doesn't work, you just need to change the container:

    
    

    Pro Tip: the container can be any selector, which is nice when you only want to override styles on a few tooltips.

提交回复
热议问题