怎么让页面和输入框文字居中对齐

来源:2-1 结构和样式

慕言_7946275

2019-08-30 16:16:51

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>简易计算器</title>
<style type="text/css">
body{
background-color: #eee;
text-align:center;
}

#calculator{

margin:200px auto;

}
</style>
</head>
<body>
<!-- 简易计算器 -->
<div id="calculator"> <!-- 父容器 -->
<p>
<input type="text" class="formerInput" value="1">
<span class="sign">+</span>
<input type="text" class="laterInput" value="1">
<span>=</span>
<span class="resultOutput">2</span>
</p>
<p>
<input type="button" value="+">
<input type="button" value="-">
<input type="button" value="×">
<input type="button" value="÷">
</p>
</div>
</body>
</html>


写回答

1回答

好帮手慕星星

2019-08-30

同学你好,

根据你的描述没有理解你的问题,意思是想要输入框中的文字在输入框中居中显示吗?

http://img.mukewang.com/climg/5d68fb6b00010ad305860155.jpg

文本框中内容默认是左对齐显示的,从body中继承来的居中显示覆盖不了,还需要自己进行设置,如下:

http://img.mukewang.com/climg/5d68fc1700013ada03160086.jpg

效果:

http://img.mukewang.com/climg/5d68fc210001f40705740109.jpg

如果没有解决你的问题,可以继续提问,建议描述清楚一些,便于帮助你解决。

祝学习愉快!

0

0 学习 · 14456 问题

查看课程