我幾乎用我的計算器應用程序來完成。我必須做的最後一件事是將兩個標籤(「First Number:」和「Second Number:」)完美對齊。我想將「First Number:」向右移動一點,以便冒號:冒號與冒號在下面排成一行。我試過將標籤分配給一個類,然後在CSS中移動它,但是這也將文本框移到了右側。這裏是我的全功能HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<link rel="stylesheet" href="styles.css">
<script src="calculator.js"></script>
</head>
<body>
<section>
<h1>Calculator</h1>
<label> </label>
<input class="noLabel" type="text" id="sum" disabled="disabled">
<br>
<label>First Number:</label>
<input type="text" id="firstNumber">
<br>
<label>Second Number:</label>
<input type="text" id="secondNumber">
<br>
<div>
<input type="button" id="calc" value="Calculate">
<input type="button" id="clear" value="Clear">
</div>
</section>
</body>
</html>
我的CSS:
input:not([type="button"]) {
margin-left: -5em;
margin-bottom: .5em;
}
input.noLabel {
margin-left:11em;
background-color: Beige;
color: blue;
}
label {
width: 11em;
float:left;
}
h1 {
color:black;
text-align:center;
}
section {
padding: 0 2em 1em;
border: grey solid;
background-color: #DCDCDC;
width: 350px;
}
div {
margin-left: 7.5em;
}
一如往常,感謝您的幫助!
結果:
嗨,你想要什麼我不明白? 用圖像描述你實際需要的東西。 –
原圖下面的新照片顯示了我正在嘗試做的事情......「第一個數字:」被轉移到右側。謝謝! – HappyHands31