0

对于我的导航栏,如何使“Arc Studios”文本可点击。

这是导航栏的图片

这是代码;

<li id="navbar-logo"><a href="#"></a>Arc Studios</li>

那么如何制作一个可点击的链接,并将 CSS 添加到文本中呢?

.menu,
.menu ul,
.menu li,
.menu a {
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

.menu {
    margin-top: -8px;
    height: 50px;
    width: 100%;
    position: absolute; right: 0; left: 0;
    text-align: left;

    background: rgb(63,76,107); /* Old browsers */
    background: -moz-linear-gradient(top, rgba(63,76,107,1) 0%, rgba(63,76,107,1) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(63,76,107,1)), color-stop(100%,rgba(63,76,107,1))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* IE10+ */
    background: linear-gradient(to bottom, rgba(63,76,107,1) 0%,rgba(63,76,107,1) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f4c6b', endColorstr='#3f4c6b',GradientType=0 ); /* IE6-9 */

    box-shadow: 0px 1px 3px #000000;

    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    border-radius: 1px;
}

.menu li {
    position: relative;
    list-style: none;
    float: left;
    display: block;
    height: 40px;
}

.menu li a { /* Navigation Bar text */
    display: block;
    padding: 0 20px;
    margin: 15px 0;
    line-height: 15px;
    text-decoration: none;

    font-family: sans-serif;
    font-weight: bold;
    font-size: 12px;

    color: #FFFFFF;
    /* text-shadow: 1px 1px 1px rgba(255,255,255,0.3); */

    -webkit-transition: color .4s ease-in-out;
    -moz-transition: color .4s ease-in-out;
    -o-transition: color .4s ease-in-out;
    -ms-transition: color .4s ease-in-out;
    transition: color .4s ease-in-out;
}

.menu li:first-child a{ border-left: none; }
.menu li:last-child a{ border-right: none; }
.menu li:hover > a { text-decoration: underline; }

.menu ul {
    position: absolute;
    top: 35px;
    left: 0;
    opacity: 0;
    background: rgba(63,76,107,1);

    border-left: 1px solid #393942;
    border-bottom: 1px solid #393942;
    border-right: 1px solid #393942;

    -webkit-border-radius: 0 0 2px 2px;
    -moz-border-radius: 0 0 2px 2px;
    border-radius: 0 0 2px 2px;

    -webkit-transition: opacity .75s ease .1s;
    -moz-transition: opacity .75s ease .1s;
    -o-transition: opacity .75s ease .1s;
    -ms-transition: opacity .75s ease .1s;
    transition: opacity .75s ease .1s;
}

.menu li:hover > ul {
    opacity: 1;
}

.menu ul li {
    height: 0;
    overflow: hidden;
    padding: 0;

    -webkit-transition: height .25s ease .1s;
    -moz-transition: height .25s ease .1s;
    -o-transition: height .25s ease .1s;
    -ms-transition: height .25s ease .1s;
    transition: height .25s ease .1s;
}

.menu li:hover > ul li {
    height: 35px;
    overflow: visible;
    padding: 0;
}

.menu ul li a {
    width: 100px;
    padding: 10px 0 10px 10px;
    margin: 0;

    border: none;
    border-bottom: 1px solid #353539;
}

.menu ul li:last-child a {
    border: none;
}

.menu li#navbar-logo {
    color: #FFC8C8;
    text-shadow: 2px 2px 2px rgba(255, 0, 0, 1);
    font-size: 50px;
    font-family: Intrique Script Personal Use;
    margin-top: -20px;
}

.menu li#navbar-home,
.menu li#navbar-about,
.menu li#navbar-shop,
.menu li#navbar-contact,
.menu li#navbar-community {
    margin-top: 5px;
}

.menu li#navbar-logo,
.menu li#navbar-home,
.menu li#navbar-about,
.menu li#navbar-shop,
.menu li#navbar-contact,
.menu li#navbar-community {
    margin-left: 5px;
}

这是所要求的CSS

4

3 回答 3

1

将文本放入 <a> 和 </a>

<li id="navbar-logo"><a href="#" class='yourClass'>Arc Studios</a></li>
于 2013-10-05T14:38:52.213 回答
1

锚标记不能与 onClick 事件绑定。为此,您必须从锚标记中删除“href”。然后它将毫无问题地工作。

<li id="navbar-logo"><a class='yourClass'>Arc Studios</a></li>
于 2013-10-05T14:46:55.577 回答
1
<li id="navbar-logo"><a href="#">Arc Studios</a></li>

并添加与此 html 对应的 CSS

#navbar-logo{
   background-color: blue; //add CSS here
 }

你的答案是这样的......这可能会帮助你http://www.w3schools.com/ 使用它......它对你有很大帮助

但是该链接中的“Arc Studio”不是文本..它是图像..您可以使用图像作为链接

<a href="#">
<img src="your_image.jpg"  width="32" height="32"></a>

它可以帮助你http://www.w3schools.com/html/tryit.asp?filename=tryhtml_imglink

于 2013-10-05T14:48:44.570 回答