我试图在窗口中居中的另一块(绿色块)的右上方放置一个块(红色块)。
绿色块是一张图片。
我怎么能做到这一点? 动态地改变块的位置,将位置定位在居中块上
#flag {position: absolute; background-color: green; height:6vw; width:15vw; color: white; text-align:center; }
#introduction {display: table; margin-left: 20%; margin-right: 20%; width: 60%; height: 100vh;}
#caser img {width: 100%; height: auto;}
#caser {padding-top:6vw; padding-bottom:6vw; display: table-cell; height: 100%; vertical-align: middle;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="flag">
<a class="linkme" id="go" target="_blank" href="https://www.google.fr/?gws_rd=ssl">
Hello
</a>
</div>
<div id="introduction">
<div id="caser"><a href="http://www.google.fr">
<img src="http://bhrabbitrescue.org/wp-content/uploads/2011/02/cute-bunnies-tongues-6.jpg">
</a>
</div>
</div>
我发布了我的第一个想法......但终于不是很好。你应该寻找一个脚本来找到图像在页面中的确切位置,以计算给你的绿色块的位置。寻找[jQuery偏移量](http://www.w3schools.com/jquery/css_offset.asp) –