Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
        <div class="inner_wrapper clearfix">
            <div class="main" id="main_body">
                <h1 class="title">ToDos</h1>
                <input type="text" placeholder="what needs to be done?" name="input_item" class="input_text" v-model="message" v-on:keyup.13="createTodo" />
                <div id="checkAll">
                    <input type="checkbox" name="choose_all" v-model="allChecked" v-on:change="checkAll"/>
                    <label class="with_cbx">Mark all as complete</label>
                </div>
                <div id="item_lists">
                    <div class='user_choice_item' v-for="todo in todos"
					  @mouseenter="showDeleteBtn($index,$event)"
                     v-on:mouseleave.self="hideDeleteBtn($index,$event)"
                    @dblclick="changeToEdit($index)">
                        <input type='checkbox' name='item_cbx' v-model="todo.checked" />
                        <label class='with_cbx_item' v-if="todo.noEdit">{{todo.content}}</label>
                        <input type="text" class="with_cbx_dbl"
                        		v-model="todo.tempMsg" v-else
                        		:value ="todo.content"
                        		@keyup.13="doneEdit($index)"
                        		@blur="doneEdit($index)"
                        />

                        <span class='delete_bt'  v-on:click.stop="deleteTodo(todo)" v-show="todo.show"></span>
                    </div>
                </div>
            </div>
            <div id="bottom" class="clearfix"  v-show="showBottom">
                <div class="float_left user_choices" >
                    <!-- 				<input type="checkbox" value=""/> -->
                    <label class="with_cbx" >
                        {{selectedNum}} items selected
                    </label>

                </div>
                <input class="delete_items  float_right" type="button" value="删除" v-on:click="deleteSelected"/>

            </div>
        </div>
    </div>



              
            
!

CSS

              
                /***************************************
	        reset style
***************************************/
body,ul,li,div,img,span,input{margin: 0;padding: 0;font: 14px "Microsoft Yahei","微软雅黑",sans-serif}

input{border: medium none;outline: none;vertical-align: middle;}
label{vertical-align: middle;}
li{list-style-type: none;}
img{border: none;}
a{text-decoration: none;cursor: pointer;color: black}
.clearfix:after{content:"";display: block;clear: both;}
/*.clearfix{overflow:hidden;}*/

.float_left{float: left;}
.float_right{float: right;}
.focus{border:2px blue solid;}

.hide{display: none;}
label.with_cbx,label.with_cbx_item{margin-left: 6px;color: white;font-weight: bold;}
input.with_cbx_dbl{background:white;color:#44c2ec;margin-left: 6px;display: inline-block;font-weight: bold;
padding: 4px 8px;
width: 75%;}

/***************************************
	        custom style
***************************************/
body,html{
	height: 100%;
}
.wrapper
{
	width: 380px;
	min-height: 250px;                    /*待修改*/
  background-color:rgb(87, 196, 200);
/* 	background:url(image/background.png) no-repeat; */
	background-size: cover;
	margin: 100px auto;

}
.inner_wrapper
{
	margin: 0 20px;
	/*border: 1px white solid;*/
	height: 100%;
	padding-top: 30px;
	position: relative;
}
#bottom
{
	/*position: absolute;             放弃绝对定位*/
	bottom: 0;
	left: 0;
	height: 40px;
	width: 334px;
	/*margin-top: 20px;*/
	/*background-color: rgba(255,255,255,0.8);*/
	padding-left: 6px;
/*	line-height: 40px;*/
}

h1
{
	color: white;
	text-align: center;
}
#main_body .input_text
{
	width: 330px;
	line-height: 40px;
	padding-left: 10px;
	background: white;
	color: rgba(0,0,0,0.5);
	margin-top: 20px;
}
#checkAll,.user_choice_item
{
	margin-top: 15px;
	vertical-align: middle;
	padding-left:6px;
	line-height: 40px;
}

#item_lists
{
	/*margin-top: 15px;*/
	width:340px;

}
.user_choice_item{
	margin-top:0;
	border-bottom:1px solid #c1c4c5;
	width: 334px;
	position: relative;
}
/*.user_choice_item span{margin-left: 20px;vertical-align: middle;}*/
.delete_bt
{
	background: url(http://i2.buimg.com/567571/4f15c12525ec98bd.png) left center no-repeat;
	width: 16px;
	height: 16px;
	position: absolute;    /*加上位置*/
	right: 15px;
	top:50%;
	margin-top: -7px;
	cursor: pointer;

}


#bottom>div{line-height: 40px;}
#bottom .delete_items
{
	padding: 4px 6px;
	margin-top: 6px;
	background: #7a9777;
	color: white;
	padding-left: 6px;
	cursor: pointer;
	position: absolute;
	vertical-align: middle;
	right: 30px;

}
              
            
!

JS

              
                /**
* Q:mouseover的时候执行多次
*/

(function(){

	var todoList = new Vue({
		el:"#item_lists",
		data:{
			todos:[],
		},
		methods:{
			showDeleteBtn:function(index,event){
				event.stopPropagation();
				if(event.currentTarget.className!=="user_choice_item")
					return;

				this.todos[index].show = true;
			},
			hideDeleteBtn:function(index,event){
				this.todos[index].show = false;

			},
			deleteTodo:function(todo){

				this.todos.$remove(todo);
				return false;
			},
			changeToEdit:function(index){
				this.todos[index].noEdit = false;
				this.todos[index].show = false;

			},
			doneEdit:function(index){
				var tempMsg = this.todos[index].tempMsg;
				this.todos[index].content = tempMsg;
				this.todos[index].noEdit = true;
			}



		}
	});

	var checkAllInput = new Vue({
		el:"#checkAll",
		computed:{
			allChecked:{
				get:function(){
					return todoList.todos.length>0 && todoList.todos.every(function(todo){
						return todo.checked;
					});
				},
				set:function(value){

					todoList.todos.forEach(function(todo,index){
						todo.checked = value;
					});

				}
			}
		}
	});

	var bottom = new Vue({
		el:"#bottom",
		computed:{
			selectedNum:function(){
				return todoList.todos.filter(function(todo){
							return todo.checked;
						}).length
			},
			showBottom:function(){
				return this.selectedNum>0?true:false
			},
		},
		methods:{
			getSelectedItems:function(){
				return todoList.todos.filter(function(todo){
					return todo.checked;
				});
			},
			deleteSelected:function(){
				this.getSelectedItems().forEach(function(todo){
					todoList.todos.$remove(todo);
				})
			}
		}
	})


	var todoInput = new Vue({
		el:".input_text",
		data:{
			message:""
		},
		methods:{
			createTodo:function(event){
				var value = createDefaultTodo(this.message);
				todoList.todos.push(value);
				this.message = "";

			}
		}
	});


	function createDefaultTodo(value){
		return {
			content:value,
			checked:false,
			show:false,
			noEdit:true
		}
	}


})();
              
            
!
999px

Console