2016-06-11 75 views
-1

你好有谁知道为什么我的左边的绿色复选框没有对齐左边的文本?这是我的代码和我现在看到的。复选框未与文本对齐

我想是这样的 “V Etendre乐林格X” 一行(V是复选框,x是销毁按钮)

enter image description here

html, 
 
body { 
 
\t margin: 0; 
 
\t padding: 0; 
 
} 
 

 
button { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t border: 0; 
 
\t background: none; 
 
\t font-size: 100%; 
 
\t vertical-align: baseline; 
 
\t font-family: inherit; 
 
\t color: inherit; 
 
\t -webkit-appearance: none; 
 
\t -moz-appearance: none; 
 
\t -ms-appearance: none; 
 
\t -o-appearance: none; 
 
\t appearance: none; 
 
} 
 

 
body { 
 
\t font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; 
 
\t line-height: 1.4em; 
 
\t background: #eaeaea url('../bower_components/todomvc-common/bg.png'); 
 
\t color: #4d4d4d; 
 
\t width: 550px; 
 
\t margin: 0 auto; 
 
\t -webkit-font-smoothing: antialiased; 
 
\t -moz-font-smoothing: antialiased; 
 
\t -ms-font-smoothing: antialiased; 
 
\t -o-font-smoothing: antialiased; 
 
\t font-smoothing: antialiased; 
 
} 
 

 
.sapUiTv, .sapUiBtnS { 
 
\t font: inherit; 
 
\t font-size: inherit; 
 
} 
 

 
#todoapp { 
 
\t background: #fff; 
 
\t background: rgba(255, 255, 255, 0.9); 
 
\t margin: 130px 0 40px 0; 
 
\t border: 1px solid #ccc; 
 
\t position: relative; 
 
\t border-top-left-radius: 2px; 
 
\t border-top-right-radius: 2px; 
 
\t box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2), 
 
\t \t \t \t 0 25px 50px 0 rgba(0, 0, 0, 0.15); 
 
} 
 

 
#todoapp:before { 
 
\t content: ''; 
 
\t border-left: 1px solid #f5d6d6; 
 
\t border-right: 1px solid #f5d6d6; 
 
\t width: 2px; 
 
\t position: absolute; 
 
\t top: 0; 
 
\t left: 40px; 
 
\t height: 100%; 
 
} 
 

 
#todoapp input::-webkit-input-placeholder { 
 
\t font-style: italic; 
 
} 
 

 
#todoapp input:-moz-placeholder { 
 
\t font-style: italic; 
 
\t color: #a9a9a9; 
 
} 
 

 
#todoapp h1 { 
 
\t position: absolute; 
 
\t top: -120px; 
 
\t width: 100%; 
 
\t font-size: 70px; 
 
\t font-weight: bold; 
 
\t text-align: center; 
 
\t color: #b3b3b3; 
 
\t color: rgba(255, 255, 255, 0.3); 
 
\t text-shadow: -1px -1px rgba(0, 0, 0, 0.2); 
 
\t -webkit-text-rendering: optimizeLegibility; 
 
\t -moz-text-rendering: optimizeLegibility; 
 
\t -ms-text-rendering: optimizeLegibility; 
 
\t -o-text-rendering: optimizeLegibility; 
 
\t text-rendering: optimizeLegibility; 
 
} 
 

 
#header { 
 
\t padding-top: 15px; 
 
\t border-radius: inherit; 
 
} 
 

 

 
#main { 
 
\t position: relative; 
 
\t z-index: 2; 
 
\t border-top: 1px dotted #adadad; 
 
} 
 

 
#new-todo, 
 
.sapUiTfBrd.sapUiTfRo.todo, 
 
.sapUiTfBrd.sapUiTfStd.todo { 
 
\t position: relative; 
 
\t margin: 0; 
 
\t margin-right: 153px; 
 
\t width: 100%; 
 
\t font-size: 24px; 
 
\t font-family: inherit; 
 
\t line-height: 1.4em; 
 
\t background-color: transparent; 
 
\t border: 0; 
 
\t outline: none; 
 
\t color: #4D4D4D; 
 
\t padding: 6px; 
 
\t -webkit-box-sizing: border-box; 
 
\t -moz-box-sizing: border-box; 
 
\t -ms-box-sizing: border-box; 
 
\t -o-box-sizing: border-box; 
 
\t box-sizing: border-box; 
 
\t -webkit-font-smoothing: antialiased; 
 
\t -moz-font-smoothing: antialiased; 
 
\t -ms-font-smoothing: antialiased; 
 
\t -o-font-smoothing: antialiased; 
 
\t font-smoothing: antialiased; 
 
} 
 

 

 
#new-todo { 
 
\t padding: 15px 15px 16px 60px; 
 
\t border: none; 
 
\t background: rgba(0, 0, 0, 0.02); 
 
\t z-index: 2; 
 
\t box-shadow: none; 
 
} 
 

 
#todo-list { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t list-style: none; 
 
} 
 

 
#todo-list li { 
 
\t position: relative; 
 
\t font-size: 24px; 
 
\t border-top: 1px dotted #ccc; 
 
} 
 

 
#todo-list input[type='checkbox'] { 
 
\t text-align: center; 
 
\t width: 40px; 
 
\t /* auto, since non-WebKit browsers doesn't support input styling */ 
 
\t height: auto; 
 
\t position: absolute; 
 
\t top: 0; 
 
\t bottom: 0; 
 
\t margin: auto 0; 
 
\t -webkit-appearance: none; 
 
\t /*-moz-appearance: none;*/ 
 
\t -ms-appearance: none; 
 
\t -o-appearance: none; 
 
\t appearance: none; 
 
} 
 

 
#todo-list input[type='checkbox']:after { 
 
\t content: '✔'; 
 
\t line-height: 62px; 
 
\t font-size: 20px; 
 
\t color: #d9d9d9; 
 
\t text-shadow: 0 -1px 0 #bfbfbf; 
 
} 
 

 
#todo-list input[type='checkbox']:checked:after { 
 
\t color: #85ada7; 
 
\t text-shadow: 0 1px 0 #669991; 
 
\t bottom: 1px; 
 
\t position: relative; 
 
} 
 

 
#todo-list input:not([type='checkbox']) { 
 
\t word-break: break-word; 
 
\t padding: 15px; 
 
\t margin-left: 45px; 
 
\t display: block; 
 
\t line-height: 1.2em; 
 
\t -webkit-transition: color 0.4s; 
 
\t -moz-transition: color 0.4s; 
 
\t -ms-transition: color 0.4s; 
 
\t -o-transition: color 0.4s; 
 
\t transition: color 0.4s; 
 
} 
 

 
#todo-list li .destroy { 
 
\t outline: none; 
 
\t background-color: transparent; 
 
\t display: none; 
 
\t position: absolute; 
 
\t top: 0; 
 
\t right: 10px; 
 
\t bottom: 0; 
 
\t width: 40px; 
 
\t height: 40px; 
 
\t margin: auto 0; 
 
\t font-size: 22px; 
 
\t color: #a88a8a; 
 
\t -webkit-transition: all 0.2s; 
 
\t -moz-transition: all 0.2s; 
 
\t -ms-transition: all 0.2s; 
 
\t -o-transition: all 0.2s; 
 
\t transition: all 0.2s; 
 
} 
 

 
#todo-list li .destroy:hover { 
 
\t text-shadow: 0 0 1px #000, 
 
\t \t \t \t 0 0 10px rgba(199, 107, 107, 0.8); 
 
\t -webkit-transform: scale(1.3); 
 
\t -moz-transform: scale(1.3); 
 
\t -ms-transform: scale(1.3); 
 
\t -o-transform: scale(1.3); 
 
\t transform: scale(1.3); 
 
} 
 

 
#todo-list li .destroy:after { 
 
\t content: '✖'; 
 
} 
 

 
#todo-list li:hover .destroy { 
 
\t display: block; 
 
} 
 

 
#todo-list .sapUiRrNoData, 
 
#todo-list .sapUiRrPtb, 
 
#todo-list .sapUiRrFtr { 
 
\t display: none; 
 
}
<html> 
 
<head> 
 
\t <meta charset="UTF-8"/> 
 
\t <title>MyTodoList</title> 
 
\t <link rel="stylesheet" href="style.css"> 
 
</head> 
 
<body> 
 
\t <section id = "todoapp"> 
 
\t \t <header id="header"> 
 
\t \t \t <h1>MyTodoList</h1> 
 
\t \t \t <form action="#" id="todo-form"> 
 
\t \t \t \t <input type="text" id="new-todo" placeholder="New task" autofocus autocomplete="off"> 
 
\t \t \t </form> 
 
\t \t </header> 
 

 
\t 
 
\t \t <section id = "main"> 
 
\t \t \t <u1 id = "todo-list"> 
 
\t \t \t \t <li> 
 
\t \t \t \t \t <div class="view"> 
 
\t \t \t \t \t \t <input type="checkbox" class="toggle"> 
 
\t \t \t \t \t \t <label>Etendre le linge</label> 
 
\t \t \t \t \t \t <button class="destroy"></button> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </li> 
 
\t \t \t </u1> 
 
\t \t </section> 
 
\t </section> 
 

 
\t <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ 
 
\t libs/angularjs/1.0.3/angular.min.js"></script> 
 

 
</body> 
 
</html>

+2

您提供的CSS数量非常可怕。您应该只提供一个不必要的部分,并使用Stack Snippets来提供可重现的演示。 – nicael

回答

2

你您的复选框上有position:absolute。删除它可以解决问题。

#todo-list input[type='checkbox'] { 
    text-align: center; 
    width: 40px; 
    height: auto; 
    /* position: absolute; */ 
    /* top: 0;    */ 
    /* bottom: 0;   */ 
    margin: auto 0; 
    -webkit-appearance: none; 
    -ms-appearance: none; 
    -o-appearance: none; 
    appearance: none; 
}