html - 相对定位里面的绝对定位

标签 html css css-position

我的短代码有点问题。 Here你会找到我的网站。
它只是一个带有按钮的图像。我的问题是,现在当我想缩放浏览器窗口时,按钮会四处移动。因此,该按钮将位于不同浏览器、计算机、手机...的任何其他位置。

这是我的代码:

<center>

<div style="position: relative; left: 0; top: 0;">
  <img src="/images/home2.png" style="position: relative; bottom: 0; left: 0;"/>
    <div style="position: absolute; right: 300; bottom: 250;">
      <a href="http://www.pugganagga.com/"><img src=" /images/button.gif " onmouseover="this.src='  /images/button2.gif '" onmouseout="this.src='  /images/button.gif '"  /></a>
    </div>
</div>

</center>

最佳答案

试试这个:

<div style="position: relative; left: 0; top: 0; margin: 0 auto; width:892px">
  <img src="/images/home2.png" style="position: relative; bottom: 0; left: 0;">
  <div style="position: absolute; right: -145px; bottom: 250;">
    <a href="http://www.pugganagga.com/"><img src="  /images/button.gif " onmouseover="this.src='  /images/button2.gif '" onmouseout="this.src='  /images/button.gif '"></a>
  </div>
</div>

关于html - 相对定位里面的绝对定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25850390/

相关文章:

css - 用什么位置互相显示DIV

jquery - 滚动时将表格标题固定到窗口顶部,跳转/跳过一行。 jQuery

javascript - 如何使用 symfony2 动态访问 twig 模板中的对象

javascript - 用于获取跨域 URL 的 iFrame 替代方案

javascript - 将鼠标悬停在链接上时激活覆盖背景

jquery - :active on dropdown select using fancyfields jquery plugin 期间背景图像的高度和宽度

html - 固定 header 上的 z-index 不起作用

html - 如何在文本溢出后显示文本 :ellipsis

javascript - 粘性标题导航菜单,当我向下滚动页面时,顶部有间隙

html - CSS 中的基本垂直中心在 float 元素上表现得很奇怪