css - 我怎样才能让我的CSS :hover work?

标签 css hover

Bellow 是我正在使用的 CSS。带有 largebutton 类的 div 可以工作,悬停除外。我希望它改变它的背景颜色,但我不确定为什么它不起作用。有什么想法吗?

编辑 - 我目前在 FF 工作。我不寻求 IE6 的支持,可能也不是 IE7。

.top .bottombar .largebutton
{
    position: relative;
    float: left;
    height: 100%;
    width: 195px;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform:uppercase;
    line-height: 33px;
    text-align: right;
    background-color: #99CCFF;
    margin-left: 5px;
    padding-right: 5px;
    overflow: hidden;
    cursor: pointer;
}

.top .bottombar .largebutton:hover
{
    background-color: #9999FF;
}

编辑 - 完整文件

HTML

<html>
    <head>
        <link rel="StyleSheet" href="css/LCARS.css" type="text/css" media="screen">
    </head>
    <body>
        <div class="top">
            <div class="content">
            </div>
            <div class="leftbuttonbox">
                <div class="button">
                Label
                </div>
                <div class="largebutton">
                Label
                </div>
                <div class="button">
                Label
                </div>
            </div>
            <div class="bottombar">
                <div class="button">
                Label
                </div>
                <div class="largebutton">
                Label
                </div>
                <div class="button">
                Label
                </div>
                <div class="label">
                    This is a label, it grows as large as it needs to
                </div>
            </div>
            <div class="cap">
                <div class="capinner">
                </div>
            </div>
        </div>
    </body>
</html>

CSS

@font-face {
    font-family: "LCARS";
    src: url('../FONT/lcars.ttf');
}

body
{
    font-family: "LCARS";
    position: relative;
    background-color: black;
    padding: 0px;
    margin: 0px;
}

.top
{
    position: relative;
    height: 220px;
    min-width: 100px;
    margin-top: 5px;
    margin-left: 5px;
    margin-right: 5px;
    background-color: #6666FF;
    -moz-border-radius-bottomleft: 50px;
}

.top .content
{
    position: absolute;
    top: 0px;
    right: 0px;
    left: 100px;
    bottom: 25px;
    background-color: black;
    -moz-border-radius-bottomleft: 25px;
}

.top .leftbuttonbox
{
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100px;
    bottom: 60px;
    background-color: black;
    overflow: hidden;
}

/*
 * the button is 1/2 the size of the large button
 * the button box can hold 4 buttons or 2 large
 * buttons or any combination of equal size
 */
.top .leftbuttonbox .button
{
    position: relative;
    height: 35px;
    width: 95px;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform:uppercase;
    line-height: 53px;
    text-align: right;
    background-color: #99CCFF;
    margin-bottom: 5px;
    padding-right: 5px;
    overflow: hidden;
    cursor: pointer;
}

.top .leftbuttonbox .button:hover
{
    background-color: #9999FF;
}

.top .leftbuttonbox .largebutton
{
    position: relative;
    height: 75px;
    width: 95px;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform:uppercase;
    line-height: 133px;
    text-align: right;
    background-color: #99CCFF;
    margin-bottom: 5px;
    padding-right: 5px;
    overflow: hidden;
    cursor: pointer;
}

.top .leftbuttonbox .largebutton:hover
{
    background-color: #9999FF;
}

.top .bottombar
{
    position: absolute;
    bottom: 0px;
    height: 25px;
    left: 200px;
    padding-right: 5px;
    background-color: black;
    overflow: hidden;
}

.top .bottombar .button
{
    position: relative;
    float: left;
    height: 100%;
    width: 95px;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform:uppercase;
    line-height: 33px;
    text-align: right;
    background-color: #99CCFF;
    margin-left: 5px;
    padding-right: 5px;
    overflow: hidden;
    cursor: pointer;
}

.top .bottombar .button:hover
{
    background-color: #9999FF;
}

.top .bottombar .largebutton
{
    position: relative;
    float: left;
    height: 100%;
    width: 195px;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform:uppercase;
    line-height: 33px;
    text-align: right;
    background-color: #99CCFF;
    margin-left: 5px;
    padding-right: 5px;
    overflow: hidden;
    cursor: pointer;
}

.top:hover .bottombar:hover .largebutton:hover
{
    background-color: #9999FF;
}

.top .bottombar .label
{
    position: relative;
    float: left;
    height: 100%;
    min-width: 50px;
    font-size: 22px;
    letter-spacing: 1px;
    font-variant: small-caps;
    padding-left: 5px;
    padding-right: 5px;
    background-color: #CC99CC;
    margin-left: 5px;
    cursor: default;
}

.top .cap
{
    position: absolute;
    height: 25px;
    width: 20px;
    right: 0px;
    bottom: 0px;
    padding-left: 5px;
    padding-right: 5px;
    background-color: black;
    cursor: default;
}

.top .cap .capinner
{
    position: relative;
    height: 100%;
    width: 100%;
    background-color: #6666FF;
    cursor: default;
    -moz-border-radius-topright: 50%;
    -moz-border-radius-bottomright: 50%;
}

最佳答案

div.top div.bottombar div.largebutton:hover
{
    background-color: #9999FF;
}

我认为这是 Firefox 中的错误。有时,当您为嵌套类添加 CSS 而没有指定这些应用到哪些元素时,浏览器会变得疯狂。您的代码在其他浏览器中工作正常,所以从技术上讲这不是您的错,而是 FF 的错;)

关于css - 我怎样才能让我的CSS :hover work?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3693439/

相关文章:

jquery - 自动化我的 slider

html - 添加没有 javascript 的悬停文本,就像我们悬停在用户的声誉上一样

css - 固定位置在上面

html - 尽管使用了位置 :absolute,但表头并未保持固定

html - CSS 溢出 :hidden creating margin at bottom

javascript - 如何关闭 Twitter Bootstrap 中页面内容包装器的填充?

CSS 亮度滤镜模糊文本

javascript - css html 仅将鼠标悬停在字母/字符区域上

html - 悬停在一个列表元素上,影响一个 div Only CSS

html - 如何在悬停对象时将 CSS 类应用于另一个元素?