定位问题(CSS弹出窗口重叠)
我的 css 弹出窗口有问题。我隐藏了跨度标签中的一些内容,并在将鼠标悬停在文本上时显示它。但存在重叠,第二行中的文本与弹出窗口重叠。而且弹出窗口的边框很乱。内容位于 此链接。我正在使用以下 css:
.rest-cat
{
clear: both;
padding: 3px 40px 0 0!important;
width: 600px;
}
.rest-menuitem
{
position: static;
float: left;
width: 254px;
padding: 3px 5px 0 0!important;
border-top: 1px dotted #DDD;
}
.dishname{
position: absolute;
z-index: 0;
float: left;
width: 229px;
}
.dishprice{
position: relative;
float: right;
width: 25px;
}
.product
{
width: 600px;
padding: 0px 0px 20px 20px!important;
}
.dishname span
{
display: none;
text-decoration: none;
}
.dishname:hover
{
overflow: hidden;
text-decoration: none;
}
.dishname:hover span
{
display: block;
position: static;
top: 0px;
left: 170px;
width: 320px;
margin: 0px;
padding: 10px;
color: #335500;
font-weight: normal;
background: #e5e5e5;
text-align: left;
border: 1px solid #666;
z-index: 200;
}
有一个简单的解决方案吗?我已经尝试过使用position:relative;并将 z-index 添加到所有 CSS 标签中。它们不起作用,我被困在上面一天了。
I have a problem with css popup. I am hidden some content in span tags and show it when I hover over a text. But there is a overlap and the text in the second line is overlapping the popup. And the border for the popup is messed up. The content is on this link. And I am using following css:
.rest-cat
{
clear: both;
padding: 3px 40px 0 0!important;
width: 600px;
}
.rest-menuitem
{
position: static;
float: left;
width: 254px;
padding: 3px 5px 0 0!important;
border-top: 1px dotted #DDD;
}
.dishname{
position: absolute;
z-index: 0;
float: left;
width: 229px;
}
.dishprice{
position: relative;
float: right;
width: 25px;
}
.product
{
width: 600px;
padding: 0px 0px 20px 20px!important;
}
.dishname span
{
display: none;
text-decoration: none;
}
.dishname:hover
{
overflow: hidden;
text-decoration: none;
}
.dishname:hover span
{
display: block;
position: static;
top: 0px;
left: 170px;
width: 320px;
margin: 0px;
padding: 10px;
color: #335500;
font-weight: normal;
background: #e5e5e5;
text-align: left;
border: 1px solid #666;
z-index: 200;
}
Is there a easy fix for this? I already tried using position: relative; and added z-index to all the CSS tags. They didn't work and I am stuck on it for a day.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的弹出窗口被裁剪的原因是因为这个CSS:
删除它将是一个很好的起点。
接下来,
z-index
仅影响具有position
属性(除static
)之外的元素。使用relative
,它们将呈现相同的效果,但 z-index 会产生影响。之后,有很多不同的事情可能会影响分层,我会像 @Michael Rader 所说的那样开始清理你的 HTML,你有很多不必要的包装器。
The reason your popups are being clipped is because of this CSS:
Removing that would be a good place to start.
Next,
z-index
only affects elements with aposition
property other thanstatic
. Userelative
and they will render the same but the z-index will have an effect.After that there are a lot of different things that could be affecting the layering I would start like @Michael Rader said by cleaning up your HTML, you have a lot of unnecessary wrappers.