<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Calculator</title>
<style>
#container {
width: 180px;
margin-left: auto;
margin-right: auto;
}
.text {
width: 200px;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div class="text">
<h2>计算器</h2>
</div>
<div id = "container">
<form action="do.php">
<input type="text" name = 'a'>
<select name="ch" id="ch">
<option value="">+</option>
<option value="">-</option>
<option value="">*</option>
<option value="">/</option>
</select>
<input type="text" name = 'b'>
<p>answer:</p>
<input type="text" name = 'ans'>
</form>
</div>
</body>
</html>
想让计算器这三个字真正的居中,而不是外面的div text居中,需要外面的div宽度等于实际文字大小,那么怎么做?(自适应,不把px写死)
相关分类