Select multiline text without overflow width

enter image description here

The top image shows an unwanted red highlight from the yellow area when you select the cross lines. I want to highlight inside the yellow part like below:

enter image description here

HTML:

<div id="parent">
    <div id="child">
        This is some content... This is a long lonnnnnnng content.
    </div>
</div>

      

CSS

#parent {
    width: 200px;
    background-color: #666;
}

#child {
    padding: 50px;
    background-color: #ff0;
}

::selection {
    background-color: #f00;
}

      

Do you know how to achieve this?

Run the code here: http://jsfiddle.net/3AESf/

+3


source to share


2 answers


You can use display: inline-block;

in #parent

to solve it



+3


source


An alternative solution, if display:inline-block

not an option, would be to add

overflow: hidden;



before #parent

. This works too.

0


source







All Articles