首页 文章

样式HTML选择和选项标签

提问于
浏览
0

我发现我可以使用一点CSS3来设置选项元素的样式 . 我试图控制鼠标悬停事件期间活动的元素的背景 . 我有效地使用了:hover选择器来控制这个功能 . 但是,当我的鼠标离开选项组时,字体仍为白色 . 有什么办法可以控制吗?

option
{
    background-image: -webkit-gradient(     linear,     left bottom,     left top,     color-stop(0, rgb(237,233,233)),     color-stop(1, rgb(255,255,255)) );
    background-image: -moz-linear-gradient(     center bottom,     rgb(237,233,233) 0%,     rgb(255,255,255) 100% );
    color:#333333;
}
option:hover
{
    background-image: -webkit-gradient(     linear,     left bottom,     left top,     color-stop(0, rgb(20,26,85)),     color-stop(1, rgb(137,145,192)) );
    background-image: -moz-linear-gradient(     center bottom,     rgb(20,26,85) 0%,     rgb(137,145,192) 100% );
    color:#FFFFFF;
}

我不知道有什么方法可以控制活动元素的字体颜色 . 这不一定是所选元素 .

1 回答

  • 1

    如果您正在为锚标记执行此操作,请在此Mainer中定义类:

    .option a{
    background-image: -webkit-gradient(     linear,     left bottom,     left top,     color-stop(0, rgb(237,233,233)),     color-stop(1, rgb(255,255,255)) );
    background-image: -moz-linear-gradient(     center bottom,     rgb(237,233,233) 0%,     rgb(255,255,255) 100% );
    color:#333333;
    }
    
    .option a:hover{
    background-image: -webkit-gradient(     linear,     left bottom,     left top,     color-stop(0, rgb(20,26,85)),     color-stop(1, rgb(137,145,192)) );
    background-image: -moz-linear-gradient(     center bottom,     rgb(20,26,85) 0%,     rgb(137,145,192) 100% );
    color:#FFFFFF;
    }
    

    它会工作正常 . 如果你还要在标签上,那么当你使用黑色时,你会看到鼠标输出形式之后悬停的东西变为正常链接 .

    如果您使用任何其他标签,请在同一个Mainer中使用

相关问题