Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 滚动菜单活动类-如何在活动类中添加字体颜色和字体大小更改?_Javascript_Html_Css_Drop Down Menu_Menuitem - Fatal编程技术网

Javascript 滚动菜单活动类-如何在活动类中添加字体颜色和字体大小更改?

Javascript 滚动菜单活动类-如何在活动类中添加字体颜色和字体大小更改?,javascript,html,css,drop-down-menu,menuitem,Javascript,Html,Css,Drop Down Menu,Menuitem,我已将活动状态添加到滚动菜单中 HTML: 我的问题是,如果我想改变字体大小和字体颜色除了背景颜色的变化?我尝试添加字体大小和其他一些,但不起作用 只需添加到css类: .active { background-color: rgba(0, 0, 0, 0.1); font-size:14pt !important; /*whatever size you want*/ color:blue !important; /*(font color)*/ } 甚至可以尝试添加“!每个属性旁边的imp

我已将活动状态添加到滚动菜单中

HTML:


我的问题是,如果我想改变字体大小和字体颜色除了背景颜色的变化?我尝试添加字体大小和其他一些,但不起作用

只需添加到css类:

.active {
background-color: rgba(0, 0, 0, 0.1);
font-size:14pt !important; /*whatever size you want*/
color:blue !important; /*(font color)*/
}

甚至可以尝试添加“!每个属性旁边的important'子句,以确保它覆盖元素的当前CSS.active{背景色:rgba(0,0,0,0.1);字体大小:14pt;!important color:white;!important}字体大小:14pt!重要的;'像这样,重要的是在结束分号之前犯了愚蠢的错误。谢谢Joakim和IndieRok我现在开始工作了。谢谢,现在我知道了'!“重要”。
<script type="text/javascript">
$(function(){
var menusections = {},
    _height  = $(window).height(),
    i        = 0;

// Grab positions of our sections 
$('.menusection').each(function(){
    menusections[this.name] = $(this).offset().top;
});

$(document).scroll(function(){
    var $this = $(this),
        pos   = $this.scrollTop();
    // Look in the sections object and see if any section is viewable on the screen. 
    // If two are viewable, the lower one will be the active one.     
    for(i in menusections){
        if(menusections[i] > pos && menusections[i] < pos + _height){
            $('a').removeClass('active');
            $('#nav_' + i).addClass('active');
        } 

    }
});
}); 
 </script>
.active {
background-color: rgba(0, 0, 0, 0.1);
 }
.active {
background-color: rgba(0, 0, 0, 0.1);
font-size:14pt !important; /*whatever size you want*/
color:blue !important; /*(font color)*/
}