php edit for Cufon font replacement

2019-03-06 14:49发布

问题:

I am trying to change the color of the menu items on my website but i don't know where in this to add the color code #c3c3c3 that i want to use

<script type="text/javascript">
jQuery(document).ready(function($){
    // Cufon font replacement & text shadows
    Cufon.replace('#sidebar .font, #content .post .font, #card-container .font, #frontwidgets h3, #gallery .gal_item .font, #nicepagination .font',{ fontFamily: 'Junction', textShadow: '#fff 0px 1px' });
    Cufon.replace('#footer .font',{ fontFamily: 'Junction', textShadow: '#000 0px -1px' });
    Cufon.replace('#content .title-container .font, #mainmenu ul.menu li:not(.current_page_item, .current-menu-parent) a.font',{ fontFamily: 'Junction', textShadow: '#<?php echo $color->bg['-4']; ?> 0px -1px' });
    Cufon.replace('#mainmenu ul.menu li.current-menu-item a.font, #mainmenu ul.menu li.current-menu-parent a.font',{ fontFamily: 'Junction', textShadow: 'none' });

    // Fixing menu hovers as cufon can't seem to handle different div-hover colors
    $('#mainmenu').find('ul.menu').children('li:not(.current-menu-item, .current-menu-parent)').hover(
        function () {
            Cufon.replace($(this).find('a.font'),{ fontFamily: 'Junction', color: '#<?php echo $color->bg['0']; ?>', textShadow: 'none' });
        },
        function () {
            Cufon.replace($(this).find('a.font'),{ fontFamily: 'Junction', color: '#<?php echo $color->fg['-2']; ?>', textShadow: '#<?php echo $color->bg['-4']; ?> 0px -1px' });
        }
    );
});
</script>

***NOTE this is a wordpress theme with font replacement by cufon and it replaces whatever is in the css so changing the css does nothing when i do it

回答1:

Your code indicates that the theme probably fetches the colors from database, which means theme author probably made it easy for you to edit these colors via WordPress dashboard, so choice 1 is look around the admin part for these options.

On the other hand, you can do it in a quick'n dirty (but perfectly valid) way, simply edit this part of your code:

<?php echo $color->bg['0']; ?>

<?php echo $color->bg['-4']; ?>

replacing it simply by color codes, like FFFFCC, or FF0000 (no need for # in front of it, as these are already in place as you'll see)



回答2:

Generally menu items are links and you can put the color change code in the css.

For example :

in HTML:

//...
<li><a href="about.php">About Us</a></li>
//...

in your CSS file:

.menu a
{
   color:Black;
}
.menu a:hover
{
   color:Maroon;
}