Skip to content

Instantly share code, notes, and snippets.

@stefang
Created September 2, 2011 11:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefang/1188406 to your computer and use it in GitHub Desktop.
Save stefang/1188406 to your computer and use it in GitHub Desktop.
Hide labels, but show on focus to replace the hidden placeholder text as a reminder
%form
%ol
%li
%label.hidden(for="the_input") The label text
%input(name="the_input" placeholder="the placeholder text")
// Span append is for the arrow point.
$("label.hidden").append('<span></span>').hide().each(function(){
$("#"+$(this).attr('for')).focus(function(){
$("label[for="+$(this).attr('id')+"]").show();
}).blur(function(){
$("label[for="+$(this).attr('id')+"]").hide();
});
});
li
position: relative
label.hidden
display: block
width: 110px
background: black
background: rgba(0,0,0,0.8)
color: #ddd
padding: 5px 10px
margin: 1px 0
font-size: 13px
line-height: 22px
position: absolute
height: 22px
top: 1px
right: -139px
+rounded(3px)
span
opacity: 0.8
width: 18px
height: 18px
position: absolute
left: -18px
top: 7px
background: url(../images/right_highlight_arrow.png)
%form
%ol
%li
%label.hidden(for="the_input") The label text
%input(name="the_input" id="the_input" placeholder="the placeholder text")
@stefang
Copy link
Author

stefang commented Sep 2, 2011

Editing gists seems to be broken, the second HAML with the ID is the working one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment