Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
378 views
in Technique[技术] by (71.8m points)

javascript - Popover for long text without spaces

I have in grid in one column long text which should be truncated in grid (ends with ...) but should show whole in popover.

The popover is displaying correctly when there are spaces in my text. For text with no spaces popover is displaying incorrectly. See examples below

Incorrect popover:

Incorrect popover

Correct popover:

Correct popover

I'm displaying popover in that way:

<div data-toggle="popover" rel="popover"
    data-container="body" data-content="My_test_in_popover">
    My_text_with_...
</div>

How should I modified code to display popover correctly for long text with no spaces?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's because Twitter bootstrap applies a max-width property to the .popover box by default (Which is max-width: 276px;).

There are two options:

1) Override the max-width by reseting that to none as:

.popover {
    max-width: none;
}

2) Or use word-wrap: break-word; CSS declaration for the popover content box as:

.popover-content {
    word-wrap: break-word;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
...