gpt4 book ai didi

html - 我想用 html 并排创建两个计算器

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:32 25 4
gpt4 key购买 nike

我正在使用 Sublime 创建两个与 html 5 并排的计算器,但最终结果是两个计算器,一个在上面,另一个在底部。

这是我的 HTML 代码:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="design2.css" >
<title>Calculator Italy</title>
</head>
<body bgcolor="skyblue">
<form>
<div id="italyCalc">
<input type="text" id="display" disabled><br>

<input type="button" id="item1" onclick="adding('1')" value="1" >
<input type="button" id="item1" onclick="adding('2')" value="2" >
<input type="button" id="item1" onclick="adding('3')" value="3" >
<input type="button" id="item1" onclick="adding('+')" value="+" ><br>

<input type="button" id="item2" onclick="adding('4')" value="4" >
<input type="button" id="item2" onclick="adding('5')" value="5" >
<input type="button" id="item2" onclick="adding('6')" value="6" >
<input type="button" id="item2" onclick="deleteLast()" value="<--" ><br>

<input type="button" id="item1" onclick="adding('7')" value="7" >
<input type="button" id="item1" onclick="adding('8')" value="8" >
<input type="button" id="item1" onclick="adding('9')" value="9" >

<input type="button" id="item1" onclick="adding('.')" value="." ><br>
<input type="button" id="item2" onclick="adding('0')" value="0" >
<input type="button" id="item2" onclick="adding('-')" value="-" >
<input type="button" id="item2" onclick="adding('*')" value="*" >
<input type="button" id="item2" onclick="adding('/')" value="/" ><br>

<input type="button" id="itemBig" onclick="adding('C')" value="C" >
<input type="button" id="item1" onclick="power('2')" value="X^2" >
<input type="button" id="itemBig" onclick="returnResult()" value="=" >

</div>
<div id="italyCalc2">
<input type="text" id="display" disabled><br>

<input type="button" id="item1" onclick="adding('1')" value="1" >
<input type="button" id="item1" onclick="adding('2')" value="2" >
<input type="button" id="item1" onclick="adding('3')" value="3" >
<input type="button" id="item1" onclick="adding('+')" value="+" ><br>

<input type="button" id="item2" onclick="adding('4')" value="4" >
<input type="button" id="item2" onclick="adding('5')" value="5" >
<input type="button" id="item2" onclick="adding('6')" value="6" >
<input type="button" id="item2" onclick="deleteLast()" value="<--" ><br>

<input type="button" id="item1" onclick="adding('7')" value="7" >
<input type="button" id="item1" onclick="adding('8')" value="8" >
<input type="button" id="item1" onclick="adding('9')" value="9" >

<input type="button" id="item1" onclick="adding('.')" value="." ><br>
<input type="button" id="item2" onclick="adding('0')" value="0" >
<input type="button" id="item2" onclick="adding('-')" value="-" >
<input type="button" id="item2" onclick="adding('*')" value="*" >
<input type="button" id="item2" onclick="adding('/')" value="/" ><br>

<input type="button" id="itemBig" onclick="adding('C')" value="C" >
<input type="button" id="item1" onclick="power('2')" value="X^2" >
<input type="button" id="itemBig" onclick="returnResult()" value="=" >

</div>
</form>
<script src="logic2.js"></script>
</body>
</html>

换句话说,我希望一个计算器放在左边,另一个放在右边,两者与顶部的距离相同。

我该怎么做?

最佳答案

你可以简单地通过给两个 div 的 float: left; 来做到这一点,就像这样:

#italyCalc, #italyCalc2 {
float: left;
}
<form>
<div id="italyCalc">
<input type="text" id="display" disabled><br>

<input type="button" id="item1" onclick="adding('1')" value="1" >
<input type="button" id="item1" onclick="adding('2')" value="2" >
<input type="button" id="item1" onclick="adding('3')" value="3" >
<input type="button" id="item1" onclick="adding('+')" value="+" ><br>

<input type="button" id="item2" onclick="adding('4')" value="4" >
<input type="button" id="item2" onclick="adding('5')" value="5" >
<input type="button" id="item2" onclick="adding('6')" value="6" >
<input type="button" id="item2" onclick="deleteLast()" value="<--" ><br>

<input type="button" id="item1" onclick="adding('7')" value="7" >
<input type="button" id="item1" onclick="adding('8')" value="8" >
<input type="button" id="item1" onclick="adding('9')" value="9" >

<input type="button" id="item1" onclick="adding('.')" value="." ><br>
<input type="button" id="item2" onclick="adding('0')" value="0" >
<input type="button" id="item2" onclick="adding('-')" value="-" >
<input type="button" id="item2" onclick="adding('*')" value="*" >
<input type="button" id="item2" onclick="adding('/')" value="/" ><br>

<input type="button" id="itemBig" onclick="adding('C')" value="C" >
<input type="button" id="item1" onclick="power('2')" value="X^2" >
<input type="button" id="itemBig" onclick="returnResult()" value="=" >

</div>
<div id="italyCalc2">
<input type="text" id="display" disabled><br>

<input type="button" id="item1" onclick="adding('1')" value="1" >
<input type="button" id="item1" onclick="adding('2')" value="2" >
<input type="button" id="item1" onclick="adding('3')" value="3" >
<input type="button" id="item1" onclick="adding('+')" value="+" ><br>

<input type="button" id="item2" onclick="adding('4')" value="4" >
<input type="button" id="item2" onclick="adding('5')" value="5" >
<input type="button" id="item2" onclick="adding('6')" value="6" >
<input type="button" id="item2" onclick="deleteLast()" value="<--" ><br>

<input type="button" id="item1" onclick="adding('7')" value="7" >
<input type="button" id="item1" onclick="adding('8')" value="8" >
<input type="button" id="item1" onclick="adding('9')" value="9" >

<input type="button" id="item1" onclick="adding('.')" value="." ><br>
<input type="button" id="item2" onclick="adding('0')" value="0" >
<input type="button" id="item2" onclick="adding('-')" value="-" >
<input type="button" id="item2" onclick="adding('*')" value="*" >
<input type="button" id="item2" onclick="adding('/')" value="/" ><br>

<input type="button" id="itemBig" onclick="adding('C')" value="C" >
<input type="button" id="item1" onclick="power('2')" value="X^2" >
<input type="button" id="itemBig" onclick="returnResult()" value="=" >

</div>
</form>

关于html - 我想用 html 并排创建两个计算器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39701615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com