Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: Why does double click select in one span also select text in another span?

With the below example, double click select on text "Goodbye" selects the text "world" in the sibling span. Why does this happen and how can it be prevented?

Markup:

<div class="col-xs-12">
    <span class="col-xs-6">Hello world</span>
    <span class="col-xs-6">Goodbye world</span>
</div>

Example:

enter image description here

Live example:

Plunker

Edit: without Bootstrap classes the behaviour is as expected, the text "world" is not selected - Plunker.

like image 487
camden_kid Avatar asked Oct 28 '25 16:10

camden_kid


1 Answers

Using Chrome's devtools to disable the CSS properties set by Bootstrap one by one suggests the issue lies with this part:

.col-xs-6 {
    float: left;
}

Unfortunately, it seems as though the float property is fundamental to Bootstrap's layout.

The issue of float causing selection oddities has previously been mentioned in this question, and the solution posted there (adding a space to the end of the first span) works in your example.

like image 78
MTCoster Avatar answered Oct 31 '25 10:10

MTCoster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!