老师,这样对吗

来源:4-3 编程练习

席萌萌

2019-09-11 15:16:03

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
<title></title>
<style type="text/css">
    *{padding:0px;margin:0px;}
    .bg{width:100%;height:5000px;
        background: url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) top left no-repeat;}
    .left{width:100px;height:200px;background: url(http://climg.mukewang.com/5a3383d00001a3dd02240364.png)  no-repeat;position:fixed;top:0px;bottom:0;left: 0px; margin-top:auto;margin-bottom: auto;}
    .right{width:100px;height:200px;background: url(http://climg.mukewang.com/5a3383c70001f1b702240364.png)  no-repeat;position:fixed;top:0px;bottom:0;right: 0px; margin-top:auto;margin-bottom: auto;}
</style>
</head>
<body>
<div class="bg">
    <div class="left"></div>
    <div class="right"></div>
</div>
</body>
</html>


写回答

1回答

好帮手慕星星

2019-09-11

同学你好,

左右两侧图片垂直居中显示了,很棒!

小建议:

1、图片没有显示完整:

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

可以将盒子设置成和图片大小一样,224X364

2、相同的样式可以进行合并:

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

先设置右侧再设置左侧,这样left会覆盖right属性,相反覆盖不了,left权重高一些。

自己再测试下,祝学习愉快!

0

0 学习 · 40143 问题

查看课程