Hover over a range icon (when its contents are larger than a space)

I am trying to view a modal window. This window contains several spans. But they are limited by width and height. And when the size of the range is smaller than the span: everything is fine, I see this icon.

But when the text is large, I could not see this icon. And I had no ideas how to do this in pure CSS without using Javascript (jQuery).

HTML:

<div class="wrapper"> <span class="first">First</span> <br/> <span class="second">Second contain a lot of text. Really long span is here</span> </div> 

CSS

 .wrapper{ width: 300px; height: 500px; background: green; overflow: hidden; } span{ display: inline-block; width: 236px; height: 30px; line-height: 30px; font-size: 16px; padding: 0px; margin: 10px 20px; padding: 0 16px 0 8px; white-space: nowrap; overflow: hidden; background: #fc0; text-overflow: ellipsis; border: 1px solid green; border-radius: 4px; } span:hover{ border: 1px solid blue; cursor: pointer; } span:hover::after{ font: normal normal normal 12px FontAwesome; line-height: 30px; content: "\f040"; float: right; } 

The first screen, the first interval: it is OK

enter image description here

Second screen, second range: this is not normal

enter image description here

Third screen, second range: it should be so

enter image description here

Any ideas? Also, the margin should be “user friendly” and the same in both cases.

Try it here:

http://codepen.io/anon/pen/KpMdvx

+7
html css css3
source share
2 answers

 .wrapper { width: 300px; height: 500px; background: green; overflow: hidden; } span { display: inline-block; width: 236px; height: 30px; line-height: 30px; font-size: 16px; padding: 0px; margin: 10px 20px; padding: 0 16px 0 8px; white-space: nowrap; overflow: hidden; background: #fc0; text-overflow: ellipsis; border: 1px solid green; border-radius: 4px; } span:hover { border: 1px solid blue; cursor: pointer; } span:hover::before { font: normal normal normal 12px FontAwesome; line-height: 30px; content: "\f040"; float: right; } 
 <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" /> <div class="wrapper"> <span class="first">First</span> <br/> <span class="second">Second contain a lot of text. Really long span is here</span> </div> 
+3
source share

Since your text has a parameter whitespace: nowrap; and comes to the end of the window, this will not work without using position: absolute; on the icon. Just give span position: relative; and apply extra right padding on hover.

0
source share

All Articles