右侧定位那个图片,为啥我设置Left:100%;不行呢?

来源:4-3 编程练习

墨菲特石头心

2019-04-18 19:11:12

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style type="text/css">

*{

padding: 0;

margin: 0;

}

.main{

width: 100%;

height: 4043px;

background: url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) top center no-repeat;

}

/*img{

display: block;

}*/

.left{

width: 224px;

height: 364px;

position: fixed;

top: 50%;

left: 0;

margin-top: -182px;

}

.right{

width: 224px;

height: 364px;

position: fixed;

top:50%;

right: 0;

left: 100%;

/*为啥这样不行呢*/

margin-top: -182px;

}

</style>

</head>

<body>

<div class="main">

<div class="left">

<img src="http://climg.mukewang.com/5a3383d00001a3dd02240364.png" />

</div>

<div class="right">

<img src="http://climg.mukewang.com/5a3383c70001f1b702240364.png" />

</div>

</div>

</body>

</html>


写回答

1回答

好帮手慕慕子

2019-04-19

同学你好, 固定定位参考的是当前浏览器窗口, 设置left:100%; 会将右侧图片移到浏览器的最右边,老师这里画图给你参考以下:

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

所以想让右侧图片固定在浏览器的右侧显示, 可以直接给图片设置right: 0; 实现

如果帮助到了你, 欢迎采纳

祝学习愉快~~~


0

0 学习 · 40143 问题

查看课程