Firefox 浮动定位和 Firefox div:hover 不工作应该如何处理?
我正在研究一些棘手的样式,该样式适用于 Safari/Webkit,但不适用于 Firefox/Gecko。我不明白到底出了什么问题。
这是我正在使用的 HTML:
<div class="showcase"><a href=><div class="showtit"><span class="showname">Stripes!</span> <span class="showtype">a theme</span> <span class="showdate">October 2009</span></div></a></div>
因此,它创建 Showcase div,然后在其中创建一个包含 Showtit div(用于定位)的链接,然后是 Showname、Showtype 和 Showdate 跨度。这就是所有的样式:
.showcase {
border-bottom-color: #eeeeee;
border-bottom-width: 1px;
border-bottom-style: solid;
font-size: 20pt;
}
.showtit {
text-align: left;
width: 800px;
margin: 0 auto;
padding: 20;
}
.showtit:hover{background-color: #3f3f3f;}
a .showcase {
color: black;
}
.showcase:hover {
background-color: #3f3f3f;
color: white;
}
.showcase a{color:black;}
.showcase a:hover {background-color: #3f3f3f;
color: white;}
.showtype {
text-transform: lowercase;
font-size: 0.7em;
color: #cecece;
}
.showdate {
z-index: 0;
top: 0.35em;
float: right;
position: relative;
font-size: 0.7em;
color: #cecece;
}
凌乱的代码,我知道,但这是在我尝试堵塞我能想到的每个泄漏之后。现在,在 Safari 上,此代码会产生如下布局:
悬停在中间的位置超过。但在 Firefox 上,我得到的是:
将鼠标悬停在同一中间。因此,div 背景悬停不起作用,而且,我在右侧对齐的跨度没有自行对齐。
这是为什么呢?我该如何解决这个问题?我如何确保这种情况不再发生?
I'm working on a tricky bit of styling that's working on Safari/Webkit but not on Firefox/Gecko. I can't figure out just what's going wrong.
Here's the HTML that I'm using:
<div class="showcase"><a href=><div class="showtit"><span class="showname">Stripes!</span> <span class="showtype">a theme</span> <span class="showdate">October 2009</span></div></a></div>
So, it creates the Showcase div, then inside that makes a link that encompasses the Showtit div (used for positioning), and then the Showname, Showtype, and Showdate spans. Here's how that's all being styled:
.showcase {
border-bottom-color: #eeeeee;
border-bottom-width: 1px;
border-bottom-style: solid;
font-size: 20pt;
}
.showtit {
text-align: left;
width: 800px;
margin: 0 auto;
padding: 20;
}
.showtit:hover{background-color: #3f3f3f;}
a .showcase {
color: black;
}
.showcase:hover {
background-color: #3f3f3f;
color: white;
}
.showcase a{color:black;}
.showcase a:hover {background-color: #3f3f3f;
color: white;}
.showtype {
text-transform: lowercase;
font-size: 0.7em;
color: #cecece;
}
.showdate {
z-index: 0;
top: 0.35em;
float: right;
position: relative;
font-size: 0.7em;
color: #cecece;
}
Messy code, I know, but this is after I've tried plugging every leak I could think of. Now, on Safari this code results in a layout like this:
Where the middle is being hovered over. But on Firefox, I instead get this:
With that same middle being hovered over. So the div background hover isn't working, and, what's more, the spans I aligned on the right aren't aligning themselves.
Why is this? How do I fix this? How do I make certain this never happens again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码有一些问题:
我建议使用下面的代码:
请注意,在 FF 中,两个包含“Stripes!”的跨度和“主题”没有对齐,而且在 IE6 中存在很大的对齐问题(我没有用其他版本测试过代码)。
编辑:要向右浮动“showdate”跨度,只需向右应用浮动并将html代码放置在其他两个跨度之前...边距顶部修复了对齐问题:
您有稍微使用 CSS 来对齐跨度“showname”和“showtype”;我不知道你想要完成什么,但我建议用下面的 html 替换这两个 span:
Your code has some issues:
I suggest the code below:
Notice that in FF the two span that contain "Stripes!" and "a theme" are not aligned, moreover you have a big alignment issue in IE6 (I've not tested the code with other versions).
EDIT: To float right the "showdate" span, just apply a float right and place the html code before the other two span(s) ... the margin-top fixes the alignment issue:
You have to play a bit with the CSS to align the span(s) "showname" and "showtype"; I don't know what you are trying to accomplish, but I suggest to replace the two span(s) with the html below: