如何在div上重叠图像?

新手上路,请多包涵

我想在 div 的边框上放置一个小的圆形登录图像,这样半个图像将在边界线之外只是为了样式目的?我想我必须设置 z-index 但如何或有任何更好的方法?

原文由 nectar 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 558
2 个回答

这正是你需要做的。

给你 img 一个类名。然后在你的样式表中添加这样的东西

#classname
{
position: absolute;
z-index: 10;
top: #distance from top of page#
left: #distance from left of page#
}

z-index 需要是一个大于你的 div 的数字,如果你没有改变它,它的索引将为 0。

希望这可以帮助。

原文由 Ash Burlaczenko 发布,翻译遵循 CC BY-SA 2.5 许可协议

.overout {
text-decoration:none;
position: relative;
z-index: 10;
top: 105px;
right: -25px;
}

原文由 nectar 发布,翻译遵循 CC BY-SA 2.5 许可协议

推荐问题