css - 如何在 CSS 中将小图像放在大图像的左下角?

标签 css

我刚刚完成我的验证码脚本,所以它有验证码图像,然后在它旁边有一个链接,该链接是一个小图像,可以单击该链接以将图像刷新为新图像。

我想让这张小图片位于大图片的左下角的顶部,有人可以用 CSS 帮助我吗?下面是我的完整代码

<img src="captcha.php?sid=<?php echo md5(uniqid(time())); ?>" id="image" align="absmiddle" />
<a href="#" onclick="document.getElementById('image').src = 'captcha.php?sid=' + Math.random(); return false">
<img src="refresh.gif" alt="Reload a new image" border="0">
</a>

最佳答案

HTML

<div id="images-container">
     <img src="image-big.png" alt="Big Image" id="big-image">
     <img src="image-small.png" alt="Small Image" id="small-image">
</div>

(如果您使用的是 XHTML,请不要忘记将图像标记的末尾更改为使用 /> 而不是 >

CSS

#images-container {
    position:relative;
}
#big-image {
    position:absolute; /* position:absolute aligns to the parent container
                          which in the HTML above is the <div> element */
    bottom:0;
    left:0;
    z-index:0;
}
#small-image {
    position:absolute;
    bottom:0;
    left:0;
    z-index:1;
}

对于 z-index 来说重要的是 #small-image#big-image 有更高的数字。如果您重复此效果,请使用类而不是 ID。

关于css - 如何在 CSS 中将小图像放在大图像的左下角?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1216461/

相关文章:

html - 如何制作只有边框线和垂直线的表格html

php - 在 PHP 中为 iPad 用户代理加载 css

CSS 选择器 - 具有给定子元素的元素

css - 使用 npm 的 Node Sass CSS 导入器

html - 如何使用 CSS 中的类删除继承的内容?

html - HTML内容背后的YouTube全屏视频

jquery - 悬停在其父 LI 上时如何触发链接悬停状态。查询

html - 背景封面仍然使图像太大

html - 如何以数学方式计算要应用于我的 CSS 的 3D 变换?

javascript - 鼠标离开 Bootstrap 导航栏时背景颜色发生变化