请老师检查 谢谢

来源:4-3 编程练习

weixin_慕粉7014616

2020-01-12 21:07:39

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

<title></title>

<style>

    *{margin:0;padding:0;}

    .a{width:100%;height:4100px;background:url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) center no-repeat;}

    .b{width:200px;height:300px;background:url(http://climg.mukewang.com/5a3383c70001f1b702240364.png)position:fixed;left:0;top:50%;margin-top: -182px;}

    .C{width:200px;height:300px;background:url(http://climg.mukewang.com/5a3383d00001a3dd02240364.png)position:fixed;right:0;top:50%;margin-top: -182px;}

</style>

</head>

<body>

    <div class="a">

        <div class="b"></div>

        <div class="c"></div>

    </div>


</body>

</html>


写回答

1回答

好帮手慕言

2020-01-13

同学你好,测试同学提供的代码,有以下问题:

1、属性值后面没有写分号,导致样式没有生效,左右两侧的图片没有显示。

建议:属性值后面要以分号作为结束。

2、左右两侧的图片没有实现垂直居中的效果。

建议:top设置50%之后,margin-top值应该为高度的一半(是负值),高度为300px,那么margin-top值应该为-150px。

代码参考:

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

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

0

0 学习 · 40143 问题

查看课程