麻烦老师看看这几个方法都对不对
来源:2-5 编程练习
qq_慕先生0342934
2020-04-19 20:33:37
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS布局</title>
<style type="text/css">
.box{
width: 500px;
height: 200px;
margin:0 auto;
border:1px solid #aaa;
background-color: #ababab;
color: #fff;
font-weight: bolder;
position: relative;
}
.box div{
width: 200px;
height: 40px;
font-size: 16px;
text-align: center;
/*此处写代码*/
/*第一种方法*/
/*margin-top: 80px;
margin-left: 150px;*/
/*第二种方法*/
/*position: relative;
top: 80px;
left: 150px;*/
/*第三种方法*/
position: relative;
top: 40px;
left: 200px;
margin-top: 40px;
margin-left: -50px;
}
</style>
</head>
<body>
<div class="box">
<div>
欢迎大家来到慕课网学习!
来到慕课网学习!
</div>
</div>
</body>
</html>
1回答
同学你好,问题解答如下:
1. 方式一正确
2. 方式二正确
3. 方式三需要优化,如下:
如果我的回答帮到了你,欢迎采纳,祝学习愉快!
相似问题
回答 1
回答 1