简体   繁体   English

悬停在上方时如何使链接文本更改颜色而不是下划线

[英]How to make the link text change color instead of underlining when hovered over

I have this menu I set up and it underlines when hovered over, but I would like it to change color, which is the default for my wordpress theme. 我已经设置了此菜单,但将鼠标悬停时会加下划线,但是我希望它更改颜色,这是我的wordpress主题的默认设置。 The title, "BOLI STYLUS" changes color exactly like I want. 标题“ BOLI STYLUS”完全按照我的意愿更改颜色。

Here is the code for the title: 这是标题的代码:

<hgroup>
                <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
                <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
            </hgroup> 

Here is the menu: 这是菜单:

菜单

Here is the style.css code for it: 这是它的style.css代码:

.header_nav ul{
    margin: 0; 
    padding: 0;
    text-align: center;
    }

.header_nav ul li{
    display: inline;
    }

.header_nav ul li a{
    float: center; 
    padding: 10.5px 11px;
    }

.header_nav ul li a:hover, .menu ul li .current{
    color: #50a9cb;
    }

Here is the header.php code: 这是header.php代码:

<div class="header_nav">
                <ul>

                            <li><a href="/pages/glifoptions">BOLI</a></li>      

                            <li><a href="/products/cosmonaut">BOLI+</a></li>

                            <li><a href="/pages/about-us">ABOUT US</a></li>

                            <li><a href="/pages/faq">FAQ</a></li>

                            <li><a href="/pages/press">PRESS</a></li>   

                    <li><a href="/cart">YOUR CART (0)</a></li>
                </ul>
            </div>

You can use the following rule, and replace XXXXXX with your desired color. 您可以使用以下规则,并用所需的颜色替换XXXXXX I assume you want to keep the styles in the same spirit, ie have the selected item also have the same style as when you hover it. 我假设您希望保持相同的风格,即使选定的项目也具有与您将鼠标悬停时相同的样式。

.header_nav ul li a:hover, .menu ul li .current
{
    color: #XXXXXX; /* replace with real value */ text-decoration: none;
}

The code that you showed already does color the text when you hover it. 您显示的代码在将鼠标悬停时确实为文本着色。 It also, however, underlines it. 但是,它也强调了这一点。 To change that add text-decoration: none; 要更改添加的文本装饰,请执行以下操作: like I did below. 就像我在下面做的那样。

.header_nav ul li a{
    float: center;
    padding: 10.5px 11px;
    **text-decoration: none;**
    }

For the complete code, see here: 有关完整的代码,请参见此处:

http://jsfiddle.net/8KPcy/1/ http://jsfiddle.net/8KPcy/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM