UI Bootstrap Popover: change width

2019-02-16 06:43发布

I'm trying to use the popovers from UI Bootstrap in AngularJS: http://angular-ui.github.io/bootstrap/#/popover

<i class="fa fa-question-circle" popover="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porta libero tincidunt, malesuada tellus vitae, dapibus ex. Ut tristique tristique eros." popover-trigger="mouseenter" popover-placement="right"></i>

It gives me a popover like this:

enter image description here

How can I style change the width of this popover?

6条回答
来,给爷笑一个
2楼-- · 2019-02-16 07:25

For me the following worked

.popover {
    max-width: 450px;
}

This actually changed the size of the popover white container.

查看更多
劳资没心,怎么记你
3楼-- · 2019-02-16 07:27

You can achieve it by overriding popover-content class:

.popover-content {
width: 200px;
}

UPDATE: You can check this in Chrome: - press F12 - select the magnifier - click on the element to inspect - modify its style enter image description here

查看更多
做自己的国王
4楼-- · 2019-02-16 07:27

From the docs you can use the

popover-class attribute - Custom class to be applied to the popover

<i class="fa fa-question-circle" popover-class="increase-popover-width" popover="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porta libero tincidunt, malesuada tellus vitae, dapibus ex. Ut tristique tristique eros." popover-trigger="mouseenter" popover-placement="right"></i>

In your style sheet

.increase-popover-width {
   max-width: 400px;
}

The reason for setting max-width instead of width is that bootstrap has popover-max-width set as 276px.

github bootstrap code

查看更多
ら.Afraid
5楼-- · 2019-02-16 07:39

Another solution if you have very wide popovers is to allow them to autosize

Just set your css to be like this

.popover {
    max-width: 800px; /* optional max width */
    width: intrinsic; /* Safari/WebKit uses a non-standard name */
    width: -moz-max-content; /* Firefox/Gecko */
    width: -webkit-max-content; /* Chrome */
}
查看更多
Anthone
6楼-- · 2019-02-16 07:43

The width can be changed easily by overriding the .popover:

.popover {
    width: 200px;
}
查看更多
一纸荒年 Trace。
7楼-- · 2019-02-16 07:49

Did you try the popover-append-to-body attribute of the popover component?

查看更多
登录 后发表回答