1
 .email-input-container>span{
  background-color: red;
  position: absolute;
  left: 10px;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s ease;
 }



input:focus + span{
  opacity: 1;
}

Link to complete code here:

http://codepen.io/Drew69/pen/gLgvxJ

Jed Fox
  • 2,979
  • 5
  • 28
  • 38
frempong69
  • 13
  • 4

3 Answers3

1

Place your <span> after the <input> field.

Do:

<div class="email-input-container">
  <input type="email" placeholder="Email">
  <span>Email</span>
</div>

Instead of:

<div class="email-input-container">
    <span>Email</span>
  <input type="email" placeholder="Email">
</div>

Hope this helps!

Saurav Rastogi
  • 9,575
  • 3
  • 29
  • 41
0

you have given your span opacity: 0, so it doesn't shows up.

the + selector applies to elements after the called element. see here:

http://www.w3schools.com/cssref/sel_element_pluss.asp

elicohenator
  • 747
  • 6
  • 17
0

you specified + which mean input and then span like this

 <div class="email-input-container">
         <input type="email" placeholder="Email">
            <span>Email</span>
    </div>
raam86
  • 6,785
  • 2
  • 31
  • 46