2017-03-29 208 views
2

我有輸入字段之間有一些小間距。我該如何刪除它?另外確認按鈕似乎與其他元素有不同的垂直位置,這是爲什麼?下面的截圖:刪除輸入字段之間的間距

enter image description here

.stockWrapper { 
 
    position: absolute; 
 
    display: block; 
 
    top: 10px; 
 
    margin: 0 auto; 
 
    width: 250px; 
 
    left: calc(50% - 75px); 
 
    padding: 0px; 
 
} 
 

 
.stock { 
 
    box-sizing: border-box; 
 
    width: 75px; 
 
    font-size: 2em; 
 
    margin: 0px; 
 
    width: 100px; 
 
    height: 50px; 
 
} 
 

 
.confirmBtn, .clearBtn { 
 
    box-sizing: border-box; 
 
    color: white; 
 
    font-weight: bold; 
 
    border: 1px solid black; 
 
    font-size: 2em; 
 
    margin: 0px; 
 
    width: 50px; 
 
    height: 50px; 
 
    padding: 0px; 
 
} 
 

 
.clearBtn { 
 
    background-color: red; 
 
} 
 

 
.confirmBtn { 
 
    background-color: green; 
 
}
<div class="stockWrapper"> 
 
    <input type="button" class="clearBtn" value="X"> 
 
    <input type="number" class="stock"> 
 
    <input type="button" class="confirmBtn" value="✓"> 
 
</div>

回答

3
  1. 輸入之間的間距是因爲新的線
  2. 要對齊按鈕垂直添加的line-height.confirmBtn.clearBtn
  3. 對於蜱符號使用適當的HTML代碼&#10003;

實施例:

.stockWrapper { 
 
    position: absolute; 
 
    display: block; 
 
    bottom: 10px; 
 
    margin: 0 auto; 
 
    width: 250px; 
 
    left: calc(50% - 75px); 
 
    padding: 0px; 
 
} 
 

 
.stock { 
 
    box-sizing: border-box; 
 
    width: 75px; 
 
    font-size: 2em; 
 
    margin: 0px; 
 
    width: 100px; 
 
    height: 50px; 
 
} 
 

 
.confirmBtn, .clearBtn { 
 
    box-sizing: border-box; 
 
    color: white; 
 
    font-weight: bold; 
 
    border: 1px solid black; 
 
    font-size: 2em; 
 
    margin: 0px; 
 
    width: 50px; 
 
    height: 50px; 
 
    padding: 0px; 
 
    line-height:48px; 
 
} 
 

 
.clearBtn { 
 
    background-color: red; 
 
} 
 

 
.confirmBtn { 
 
    background-color: green; 
 
}
<div class="stockWrapper"> 
 
    <input type="button" class="clearBtn" value="X"><input type="number" class="stock"><input type="button" class="confirmBtn" value="&#10004;"> 
 
</div>

3

你有標籤之間的一些非打印字符(隱藏)。請使用:

<div class="stockWrapper"><input type="button" class="clearBtn" value="X"><input type="number" class="stock"><input type="button" class="confirmBtn" value="✓"></div>