Как я могу заставить мой css: hover работать? - PullRequest
1 голос
/ 12 сентября 2010

Пыльник - мой css, которым я пользуюсь. DIV с классом largebutton работает за исключением парения. Я хотел бы изменить цвет фона, но не уверен, почему он не работает. Есть идеи?

edit - Я сейчас работаю в 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;
}

edit - Полные файлы

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%;
}

Ответы [ 3 ]

1 голос
/ 12 сентября 2010
div.top div.bottombar div.largebutton:hover
{
    background-color: #9999FF;
}

Я думаю, что это ошибка в Firefox.Иногда, когда вы добавляете CSS для вложенных классов без указания элементов, к которым они применяются, браузер сходит с ума.Ваш код работает нормально в других браузерах, так что технически это не ваша вина, а FF;)

1 голос
/ 12 сентября 2010

Я предлагаю это решение:

.top .largebutton:hover
{
    background-color: #9999FF; /* make this whatever color it was before */
}

Это сработало для меня, когда я попробовал его с вашим полным кодом.Надеюсь, что это работает для вас:)

Amit

0 голосов
/ 12 сентября 2010

Ключевая концепция стилизации ссылки заключается в следующих шагах:

  1. Вы должны объявить стили 4 различных условий: a:link, a:visited, a:hover, a:active.
  2. Вы должны быть осторожны с заказом.Потому что это важно.ссылка> посетил> парить> активно.(особенно чтобы иметь: hover и: посещенную работу ...)
  3. Даже если вам не нужно разрабатывать одно или несколько условий, тем не менее, стилизуйте их все.

Если выобратите внимание на них, у вас могут быть идеально стилизованные ссылки.

Надеюсь, это поможет.

...