如何在div上重叠图像?
我想在 div
的边框上放置一个小的圆形登录图像,这样一半图像将在边框线之外,只是为了样式目的?我想我必须设置 z-index 但 OR 是如何存在的还有更好的办法吗?
I want to place a small circular login image on the border of div
such that half image will be outside the border line just for style purpose?I think I have to set z-index but how OR is there any better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这正是您需要做的。
给你 img 一个类名。然后在样式表中添加类似
z-index 的数字,该数字必须大于 div,如果您没有更改它,则其索引将为 0。
希望这有帮助。
Thats exactly what you need to do.
Give you img a class name. Then in your style sheet add something like this
z-index needs to be a number greater than your div which will have an index of 0 if you haven't changed it.
Hope this helps.
您可以使用 div 轻松地做到这一点。考虑下面的代码,
您所要做的就是用“background-image”属性替换第二个 div 的“background-color”属性,并将该 div 嵌套在现有的 div 中。确保您的 div 大小与您的徽标完全相同,并设置背景重复:无重复;
希望有帮助。测试我发布的示例代码。您可以将所有样式信息放入 css 类中,如下所示:
You can do this very easily using divs. Consider the following code
All you have to do is replace the second divs "background-color" property with the "background-image" property and nest that div inside your existing div. Make sure you make the div the exact size of your logo and set background-repeat: no-repeat;
Hope that helps. Test the example code I posted. You can place all the style information into a css class like this: