麻烦老师看看这几个方法都对不对

来源: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回答

好帮手慕久久

2020-04-20

同学你好,问题解答如下:

1. 方式一正确

2. 方式二正确

3. 方式三需要优化,如下:

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

如果我的回答帮到了你,欢迎采纳,祝学习愉快!


0
hq_慕先生0342934
h 嗯,好的,请问这样设置有什么好处么?为啥要这样设置呢?
h020-04-20
共1条回复

0 学习 · 40143 问题

查看课程