2013-02-02 19 views
3

enter image description here没有溢出选择多行文本的宽度

向上图像显示出来的黄色区域的不必要的红选择当您选择十字线。我要黄色部分中选择,如下所示:

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; 
} 

你知道如何实现这一目标?

运行代码在这里:http://jsfiddle.net/3AESf/

回答

3

您可以使用display: inline-block;#parent解决它

+0

谢谢!这正是我想要的! – Ovilia

+0

在高级中,您还可以将'padding:50px;'从'#child'移动到'#parent'。比你只在'小孩'容器内选择。 – insertusernamehere

0

另一种解决方案,如果display:inline-block不会是一个选项,将添加

overflow: hidden;

#parent。这也起作用。