Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="box" id="Vue">
	<div class="clerafix mb10">
		<input type="text" v-model="todo" class="w300 inpTxt01" v-on="keydown : onKeydown">
		<button class="inpBtn01" v-on="click : push">追加</button>
		<button class="inpBtn02" v-on="click : clear">全て削除</button>
	</div>
	<ul class="lastItem todoList">
		<li v-repeat="list">
			{{$index + 1}}.<span class="ml10">{{todo}}</span>
			<a class="disRight" href="javascript:void(0)" v-on="click : slice($index)">削除</a>
		</li>
	</ul>
</div>
            
          
!

CSS

            
              @charset "UTF-8";


/* ------------------------------------------------------------
init
------------------------------------------------------------ */

html {
	margin: 0;
	padding: 0;
	font-size: 62.5%;
}

body {
	margin: 0;
	padding: 0;
	font-weight: normal;
	font-style: normal;
	font-size: 1.3rem;
	font-size: 13px;
	font-family: sans-serif;
	line-height: 1.5;
	font-family: 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', 'メイリオ', Meiryo, Osaka, 'MS Pゴシック', 'MS PGothic', Verdana, Arial, Helvetica, sans-serif;
	-webkit-text-size-adjust: none;
	-moz-text-size-adjust: none;
	-ms-text-size-adjust: none;
}

em, strong {
    font-style: normal;
    font-weight: bold;
}

ul {
	margin: 0;
	padding: 0;
}

li {
	list-style: none;
}

/* ------------------------------------------------------------
clearfix
------------------------------------------------------------ */
.clearfix:after {
	display: block;
	visibility: hidden;
	clear: both;
	height: 0;
	content: ".";
}

/* ------------------------------------------------------------
Parts
------------------------------------------------------------ */

.box{
	border-radius: 3px;
	padding: 10px;
	width: 800px;
}

ul.todoList{
	border-radius: 3px;
	overflow: auto;
}

ul.todoList li{
	border-bottom: 1px dotted #cccccc;
	padding: 10px;
	position: relative;
	cursor: pointer;
	font-size: 120%;
}

ul.todoList li .disRight{
	position: absolute;
	text-decoration: none;
	right: 10px;
}

ul.todoList li:last-child{
	border-bottom: none;
}

.inpBtn01{
	padding: 8px 20px;
	background: #337ab7;
	border: 1px solid #337ab7;
	border-radius: 3px;
	color: #ffffff;
	cursor: pointer;
}

.inpBtn02{
	padding: 8px 20px;
	background: #d9534f;
	border: 1px solid #d9534f;
	border-radius: 3px;
	color: #ffffff;
	cursor: pointer;
}


.inpTxt01{
	border: 1px solid #cccccc;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	font-size:  138.5%;
	padding: 5px;
	border-radius: 3px;
	vertical-align: middle;
}

.inpTxt01:focus{
	background: #CDE7F1;
}

.ml10{
	margin-left: 10px;
}

.mb10{
	margin-bottom: 10px;
}
            
          
!

JS

            
              var JsonData = []; // グローバル変数を宣言

if(window.localStorage){// localStorageが使用できるかチェック
	if(window.localStorage.getItem("JsonData")){// JsonDataがキーとしてあるかチェック
		var json = window.localStorage.getItem("JsonData");// JsonDataを取り出し
		JsonData = JSON.parse(json); // 文字列をオブジェクトに変換
	}
}

// localStorageに、キー名とオブジェクトをセット
function setLocalStorage(setKey , jsonData){
	var json = JSON.stringify(jsonData); //オブジェクトを文字列に変換
	window.localStorage.setItem(setKey , json);// オブジェクトをlocalStorageに保存
}

  // Vue インスタンスの生成
	var vm = new Vue({
		el: '#Vue', //データバインディングの対象となる、DOM要素を指定
		data: { //モデルとなるオブジェクトを指定
			'list': JsonData, //localStorageに保存された、JsonDataをセット
			'todo' : '' //空のオブジェクトをセット
		} ,
		methods: {
			'push' : function(){
				this.list.push({'todo': this.todo}); // todoオブジェクトをlistに追加
				this.todo = ''; // todoオブジェクトを空にする
				setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			},
			'slice' : function(index){
				this.list.splice(index , 1); // 指定されたインデックスの要素を削除
				setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			} ,
			'onKeydown' : function(e){
				if(e.keyCode === 13){ // Enterキーが押されると、pushメソッドが実行
					this.push();
				}
			} ,
			'clear' : function(){
				this.list = []; //list要素を全て空に
        setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			}
		}
	});
            
          
!
999px

Console