Skip to content

Instantly share code, notes, and snippets.

@nickstamas
Created March 30, 2012 19:13
Show Gist options
  • Select an option

  • Save nickstamas/2254175 to your computer and use it in GitHub Desktop.

Select an option

Save nickstamas/2254175 to your computer and use it in GitHub Desktop.
Untitled
body {
background: #ecf1f1;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
button {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
ol {
padding: 0;
margin: 0;
}
.actions {
background: rgba(0,0,0,0.3);
width: 200px;
padding: 20px;
}
.actions .add-item {
font-size: 14px;
margin: 0 auto;
}
.new-dispatch {
width: 550px;
background: #fff;
padding: 25px;
border-top: 8px solid #f76400;
box-shadow: rgba(0,0,0,0.07) 0 1px 10px;
margin: 30px auto;
position: relative;
}
button.create {
position: absolute;
right: 20px;
top: 20px;
border: 0;
background: #41d9d9;
font-size: 14px;
color: #298484;
font-weight: bold;
padding: 5px 15px;
cursor: pointer;
}
form {
margin-top: 25px;
}
.form-row {
border-bottom: 1px solid #eee;
padding: 0 10px 10px 10px;
position: relative;
overflow: hidden;
}
.form-row label {
font-size: 12px;
font-weight: bold;
color: #bbb;
position: absolute;
bottom: 10px;
text-align: right;
width: 35px;
}
.form-row label.active {
color: #41d9d9;
}
input, textarea {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
background: none;
outline: none;
border: 0;
width: 420px;
resize: none;
font-size: 14px;
}
textarea {
margin: 10px 0 0 40px;
padding: 6px;
}
.form-row input[type=text] {
border: 0;
margin: 0 0 0 40px;
position: relative;
top: 6px;
padding: 6px;
}
.form-row input.title {
font-size: 22px;
font-weight: bold;
height: 22px;
padding: 6px;
position: relative;
top: 7px;
}
.form-row label.note {
top: 17px;
}
.item-container {
margin-top: 25px;
min-height: 80px;
background: #f3f3f3;
}
.item-container .no-items {
line-height: 80px;
font-size: 12px;
font-weight: bold;
text-align: center;
color: #aaa;
}
.item-container .items {
list-style: none;
min-height: 80px;
overflow: hidden;
display: none;
}
.item-container .items .item {
width: 100px;
min-height: 100px;
background: #eee;
display: inline-block;
float: left;
margin: 5px;
}
.item-container .items .item .thumb-wrapper {
position: relative;
}
.item-container .items .item:hover .thumb-wrapper .remove {
display: block;
}
.item-container .items .item .thumb-wrapper .remove {
position: absolute;
z-index: 100;
width: 15px;
height: 15px;
background: red;
right: 3px;
top: 3px;
display: none;
border-radius(999px);
}
.item-container .items .item .thumb-wrapper .overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
}
.item-container .items .item .thumb-wrapper:hover {
cursor: pointer;
}
.item-container .items .item .thumb-wrapper:hover .overlay {
opacity: 0.2;
}
.item-container .items .item .thumb-wrapper:hover + .item-name {
color: #000;
}
.item-container .items .item .item-name {
color: #000;
font-size: 11px;
line-height: 100px;
text-align: center;
}
<div class='actions'>
<button class='add-item'>Add Item</button>
</div>
<div class='new-dispatch'>
<button class='create'>Create</button>
<form>
<div class='form-row'>
<label>TITLE:</label>
<input type='text' class='title' placeholder='New Dispatch'>
</div>
<div class='form-row'>
<label>TO:</label>
<input type='text'>
</div>
<div class='form-row'>
<label class='note'>NOTE:</label>
<textarea></textarea>
</div>
</form>
<div class='item-container'>
<div class='no-items'>+ DRAG ITEMS HERE</div>
<ol class='items'></ol>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
$(".form-row").click(function(e) {
var $row = $(e.target).closest(".form-row");
$row.find("input:first, textarea:first").focus();
});
$('input, textarea').focus(function(e) {
$('label').removeClass('active');
var $row = $(e.target).closest('.form-row');
$row.find('label').addClass('active');
});
$(".add-item").click(function() {
$(".no-items").hide();
$(".items").show();
$item = $("<li class='item'></li>");
$remove = $("<div class='remove'></div>");
$remove.click(function(e) {
$(e.target).closest(".item").remove();
});
$thumb = $("<div class='thumb-wrapper'><div class='overlay'></div><img src='http://placekitten.com/99/100' /></div>");
$thumb.append($remove);
$item.append($thumb);
var kittyNames = ["nickycat.jpg", "jessepuss.jpg", "joelion.png", "alexakitty.gif", "garyleopard.png"]
var name = kittyNames[Math.round(Math.random()*4)];
$item.find('.overlay').append("<div class='item-name'>" + name + "</div>");
$(".items").append($item);
});
});
</script>
{"view":"split","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment