我正在尝试在我的网站之一上放置丝带图像。不幸的是,我无法弄清楚为什么它不能像我想要的那样工作。我使用 position: relative;
和 position: absolute;
来完成所有定位工作,但问题是图像不在顶部:
我已经习惯了以下代码:
.ribbon { position: relative; }
.ribbon h3 {
background: url("images/ribbon.png") no-repeat scroll 0 0 transparent;
color: #FFFFFF;
font-family: Tahoma,arial,serif;
font-size: 1.4em;
height: 34px;
padding: 7px 0 0 17px;
position: absolute;
right: -36px;
width: 244px;
z-index: 200;
}
如果你想看看这个网站,你可以这样做on this link (用户:tmp/密码:tmpuser)。
它应该是这样的:
最佳答案
看起来外部 DIV 宽度太小,无法容纳所有内容,并且将图像向下推。
尝试将主/包装 DIV 的宽度设置为更大的宽度,看看是否可行。
关于CSS:绝对定位图像 - 但它不在顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5587020/