Skip to content

Instantly share code, notes, and snippets.

@seb
Created February 1, 2016 15:54
Show Gist options
  • Save seb/fdc1a1463174a9f6946f to your computer and use it in GitHub Desktop.
Save seb/fdc1a1463174a9f6946f to your computer and use it in GitHub Desktop.
#css
.info,#people{display:block;width:100%}
.person{display:inline-block;width:30%}
<dic id="people">
<div class="person" data-name="John Lennon" data-content="Lorem Ipsum..."><img src="photo.jpg" /></div>
<div class="person" data-name="Paul McCartney" data-content="Lorem Ipsum..."><img src="photo.jpg" /></div>
<div class="info"></
</div>
# Dans le JS :
$(document).on 'click', ".person" , (e) ->
$(".info").removeClass("visible")
name = $(this).data(name)
content = $(this).data(content)
$(".person").nth-child(num_of_item_per_lines).append("<div class='info'>" + name "</div>")
$(".info").addClass("visible")
$.ready ->
num_of_item_per_lines = parseInt($("#people").width()/$(".person).fisrt().width()) # 3 ou 5 ou 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment