【发布时间】:2013-08-08 14:17:04
【问题描述】:
希望图像文件出现在页面的固定位置。
写了如下代码:
<style>
.hovering-image{
position: fixed;
left: 70%;
top:20%;
height: 20%;
width 10%;
}
</style>
<body>
<div class="hovering-image">
<img src="whatever.jpg">
</div>
</body>
但是,图像会随着窗口大小的调整而变长并改变比例。有没有更好的方法让图像显示在固定位置并随着窗口大小调整而缩放而不失真?
【问题讨论】:
-
更新了你的标签,记得使用 twitter-bootstrap-3
-
你的 CSS 中有一个错误:
width 10%;应该是width: 10%;,这可能是你的问题,因为你没有给这个img提供宽度。
标签: css html twitter-bootstrap-3