Tag Input

HTML
<div class="tags"> <div class="tag-container"> <span class="tag-item">Tag 1 <i class="tag-close"></i></span> <span class="tag-item">Tag 1 <i class="tag-close"></i></span> </div> <div class="input-container"> <input placeholder="Add tag" class="input-tag" type="text" /> </div> </div>
CSS
body { background-color: #eee; padding: 10px; } .tags { overflow: auto; background-color: white; border: 1px solid #ccc; border-radius: 5px; padding: 8px; } .tag-container{ float: left; } .tag-item { border: 1px solid #ccc; display: inline-block; padding: 2px 8px; } .tag-close { display: inline-block; height: 12px; width: 12px; margin: 0 0 0 2px; vertical-align: base; background: url("data:image/svg+xml;base64,PHN2ZyB2aWV3UG9ydD0iMCAwIDEyIDEyIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGxpbmUgeDE9IjEiIHkxPSIxMSIgeDI9IjExIiB5Mj0iMSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIi8+PGxpbmUgeDE9IjEiIHkxPSIxIiB4Mj0iMTEiIHkyPSIxMSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIi8+PC9zdmc+"); } .input-container { overflow: auto; padding: 0 0 0 10px; } .input-tag { box-sizing: border-box; border: 0; padding: 3px; width: 100%; }
JAVASCRIPT
Expand for more options Login