Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover edit icon on span (when its content is longer than span)

Tags:

html

css

I try to view show modal window. This window contain multiple span. But there are limited by width and height. And when span content is smaller, than span width: all is OK, I can see this icon.

But when text is to big I could not see this icon. And I didn't have any ideas, how to do this on 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;
}

First screen, first span: it's OK

enter image description here

Second screen, second span: it's not normal

enter image description here

Third screen, second span: so must be

enter image description here

Have any ideas? Also padding, margin must be "user-friendly" and the same in both cases.

Try it here:

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

like image 723
brabertaser19 Avatar asked May 16 '15 09:05

brabertaser19


1 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>
like image 174
Ashesh Avatar answered Sep 27 '22 19:09

Ashesh