3 回答
TA贡献1831条经验 获得超10个赞
使用如下所示的溢出:隐藏功能
.buttonsBody { width: 100%; height: 80%; border-top: 0px; background-color: rgb(138, 142, 143); overflow: hidden; }
该功能将阻止任何内容离开您的父 div,这样您就可以调整父 div 的大小以适合您需要的内容,并且它将阻止内容出现在外部
TA贡献1854条经验 获得超8个赞
你可以使用以下方法。添加你自己的类并根据它编写css。如果你不想使用bootstrap,你可以使用css grid,这对你来说很容易
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<meta charset="UTF-8"/>
<style>
html, body {
text-align: center;
font-family: 'Courier New', Courier, monospace;
width:100%;
}
.mainBody {
display: inline-block;
width: auto;
height: auto;
}
.outputWindow {
height: 20%;
border-bottom: 0px;
background-color: rgb(164, 174, 177);
text-align: right;
line-height: 100px;
padding:20px;
}
.buttonsBody {
border-top: 0px;
background-color: rgb(138, 142, 143);
}
.numColumn, .operatorColumn {
display: inline-block;
width: 100%;
height: 100%;
}
.numButton, .operatorButton {
width:20%;
float:left;
line-height: 50px;
margin:10px;
border: 1px solid black;
}
.numButton {
height: 25%;
}
.operatorButton {
height: 25%;
}
</style>
</head>
<body>
<div class="mainBody">
<div class="outputWindow">Test </div>
<div class="buttonsBody">
<div class="numColumn">
<div class="numButton">7</div>
<div class="numButton">8</div>
<div class="numButton">9</div>
<div class="numButton">Del</div>
</div>
<div class="numColumn">
<div class="numButton">4</div>
<div class="numButton">5</div>
<div class="numButton">6</div>
<div class="numButton">÷</div>
</div>
<div class="numColumn">
<div class="numButton">1</div>
<div class="numButton">2</div>
<div class="numButton">3</div>
<div class="numButton">x</div>
</div>
<div class="operatorColumn">
<div class="operatorButton">0</div>
<div class="operatorButton">.</div>
<div class="operatorButton">=</div>
<div class="operatorButton">-</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
- 3 回答
- 0 关注
- 105 浏览
添加回答
举报