徽标超链接不起作用

时间:2013-12-26 21:12:26

标签: html css

我希望在我的网站内部有一个徽标,其中包含一个链接到youtube内部的超链接我为更多网站制作了这个我之前构建的但不知何故这在本网站中不起作用也许它与图层有关?

注意:我只是发送我的整个网站,它不是太大,我不介意复制,因为我是一名学生,并这样做教育:)

HTML code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="../jquery-easing.js"></script>
<script type="text/javascript" src="java.js"></script>

<head>
<link rel="stylesheet" href="css/style.css" type="text/css"/>
<title>Test Website</title>
<meta name="" content="">

<script type="text/javascript">

        function Slider(){
            $(".slider #1").show("fade",500);
            $(".slider #1").delay(5500).hide("slide",{direction: 'left'},500);

            var sc=$(".slider img").size();
            var count=2;

        setInterval(function(){
            $(".slider #"+count).show("slide",{direction: 'right'},1000);
            $(".slider #"+count).delay(5500).hide("slide", {direction: 'left'},500);

            if(count == sc){
                count = 1;
            }else{
                count=count + 1;
            }       
        },7000);
};

$( document ).ready(function() {
    $('#menubar, #leftmenu, #rightmenu').on('click', 'a', function(e) {
    e.preventDefault(); // prevents default scrolling
    var y = $(this.hash).offset().top; // grabs the #id element offset location
    $('html,body').animate({scrollTop: y-150},750); // animate the scroll
});
});

</script>

</head>
<body onload="Slider();">

<header>

    <div id="title">
    <h1 class="headertext">Test Website</h1>
    </div>

    <div id="menubar">
        <ul>
          <li><a href="#content">slideshow</a></li>
          <li><a href="#naturepictures">naturepictures</a></li>
          <li><a href="#hello">homepage</a></li>
          <li><a href="#hello">homepage</a></li>
          <li><a href="#hello">contact</a></li>         
      </ul>
     </div>

</header>
    <div class="hide"></div>

    <div id="container">

        <div id="rightmenu">
            <ul>
                <li><a href="#content">slideshow</a></li>
                <li><a href="#naturepictures">naturepictures</a></li>
                <li><a href="#hello">homepage</a></li>
                <li><a href="#hello">homepage</a></li>
                <li><a href="#hello">contact</a></li> 

                <div id="youtubelogo">
                <a href="http://www.youtube.com" target="_blank">
                <img src="images/youtubelogo.gif" alt="" width="90" height="50" align="middle">
                </a>
                </div>

            </ul>
        <div id="righttriangle1"></div>
        <div id="righttriangle2"></div>
        <div id="righttriangle3"></div>
        <div id="righttriangle4"></div>
        <div id="righttriangle5"></div>
        </div>

        <div id="leftmenu">
        <ul>
            <li><a href="#content">slideshow</a></li>
                <li><a href="#naturepictures">naturepictures</a></li>
                <li><a href="#hello">homepage</a></li>
                <li><a href="#hello">homepage</a></li>
                <li><a href="#hello">contact</a></li>
        </ul>
        <div id="lefttriangle"></div>
        </div>      

        <div id="content">

            <h1>Contentpage</h1><br>

            Picture slideshow
            <br>
            <br>

            <div class="slider">
                <img id="1" src="images/car1.jpg" border="0" alt="car1"/>
                <img id="2" src="images/car2.jpg" border="0" alt="car2"/>
                <img id="3" src="images/car3.jpg" border="0" alt="car3"/>
                <img id="4" src="images/car4.jpg" border="0" alt="car4"/>
                <img id="5" src="images/car5.jpg" border="0" alt="car5"/>
            </div><!--slider end-->

            <div class="shadow"></div>  

            <div id="naturepictures">

            <h1>Pictures</h1>
            <br>
            <img style="width: 800px; height: 600px; margin-left: -310px;" src="images/nature1.gif"/>

            </div><!--hello end-->

    </div><!--content div-->

    </div>


</body>
</html>

CSS代码:

*{
    margin: 0 auto 0 auto;
    text-align: left;
    color: #ffffff;
}

body{
    margin: 0;
    text-align: left;
    font-size: 13px;
    font-family: arial, helvetica, sens-serif;
    color: #ffffff;
    width: 1200px;
    height: auto;
    background: #fdf7e3;
}

header {
    position: fixed;
    width: 100%;
    top: 0;
    background: rgba(0,0,0,0.8);
    z-index: 10;
}

h1{
    color: black;
    text-align: center;
}

.hide
{
    position: fixed;
    width: 100%;
    top: 0;
    background: rgba(255,255,255,1);
    z-index:5;  
    height: 123px;
}
.headertext{
    margin-top: 15px;
    text-align: center;
    color: white;
}

#title{     
    font-size: 20px;
    margin: -10px 0 30px 0;
    width: 100%;
    height: 70px;
    border-top: 2px solid #000000;
    border-bottom: 2px solid #000000;
}

#menubar{
    margin-top: 10px;
    float: left;
    clear: both;
    width: 100%;
    height: 20px;
    list-style: none;
    border-bottom: 2px solid #010000;
}

#menubar ul{
    list-style: none;
    margin-top: -20px;
    text-align: center;
}

#menubar ul li{
    list-style: none;
    display: inline;
    padding-right: 80px;
}

#menubar ul li a{
    color: #ffffff;
    text-decoration: none;
    font-size: 20px;
    font-weight: bold;
}

#menubar ul li a:hover{
    border-bottom: 2px solid #ffffff;
}

#container{
    width: 1200px;
    height: 1400px;
}

#rightmenu{
    position: fixed;
    margin-top: 23px;
    margin-left: 1280px;
    padding-top: 20px;
    float: left;
    width: 160px;
    height: 530px;
    list-style: none;
    background: rgba(0,0,0,0.8);
    color: #ffffff;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

#rightmenu ul li{
    display: block;
    padding-bottom: 50px;
}

#rightmenu ul li a{
    font-weight: bold;
    text-decoration: none;
    color: #ffffff;
    font-size: 15px;
    text-align: center;
    margin-left: -15px;
}

#rightmenu ul li a:hover{
    border-bottom: 2px solid #ffffff;
    transition: opacity .5s ease-in;
    opacity: 1;
}

#righttriangle1 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-top: -410px;
   margin-right: 160px;
}

#righttriangle2 {
    width: 0;
    height: 0;
    border-right: 25px solid rgba(0,0,0,0.8);
    border-top: 34px solid transparent;
    border-bottom: 34px solid transparent;
    margin-right: 160px;
}

#righttriangle3 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#righttriangle4 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#righttriangle5 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#youtubelogo{

}

#leftmenu{
    position: fixed;
    margin-top: 23px;
    margin-left: 50px;
    padding-top: 20px;
    float: left;
    width: 160px;
    height: 450px;
    list-style: none;
    background: rgba(0,0,0,0.8);
    color: #ffffff;
    border-left: 2px solid #010000;
    border-right: 2px solid #010000;
}

#leftmenu ul li{
    display: block;
    padding-bottom: 50px;
}

#leftmenu ul li a{
    font-weight: bold;
    text-decoration: none;
    color: #ffffff;
    font-size: 15px;
    margin-left: -15px;
}

#leftmenu ul li a:hover{
    border-bottom: 2px solid #ffffff;
    transition: opacity .5s ease-in;
    opacity: 1;
}

#lefttriangle{
    margin-top: 112px;
    margin-left: -1px;
    width: 0px; 
    height: 0;
    border-top: 80px solid rgba(0,0,0,0.8);
    border-left: 82px solid transparent; 
    border-right: 82px solid transparent; 
}

#content{
    margin-top: 100px;
    margin-left: 100px;
    width: 1000px;
    padding-top: 50px;
    padding-left: 160px;
    color: #000000;
    font-weight: bold;
    text-align: center;
    font-size: 15px;
    margin-left: 80px;
}

#naturepictures{
    color: black;
    top: 1200px;
    width: 80px;
    height: 300px;
    text-align: center;
    margin-left: 440px;
}

.naturepicture{
    height: 400px;
    width: 600px;
}

.slider{
    margin-top: 20px;
    width: 600px;
    height: 400px;
    overflow: hidden;
    margin: auto;
    border-radius: 10px;
    vertical-align: middle;
}

.shadow{
    background-image:url(../images/shadow.png);
    background-repeat: no-repeat;
    background-position: top;
    width: 850px;
    height: 144px;
    vertical-align: middle;
    margin-top: -50px;
}

.slider img{
    width: 600px;
    height: 400px;
    display: none;
}

提前致谢,我希望您能快速获得解决方案! (这可能是一件非常简单的事情:p)

3 个答案:

答案 0 :(得分:0)

您无法使<div>元素成为<ul>元素的直接子元素。您需要先将<div>包含在<li>元素内。

试试这个

<ul>
    <li><a href="#content">slideshow</a></li>
    <li><a href="#naturepictures">naturepictures</a></li>
    <li><a href="#hello">homepage</a></li>
    <li><a href="#hello">homepage</a></li>
    <li><a href="#hello">contact</a></li> 
    <li>
        <div id="youtubelogo">
            <a href="http://www.youtube.com" target="_blank">
                <img src="images/youtubelogo.gif" alt="" width="90" height="50" align="middle" />
            </a>
        </div>
    </li>
</ul>

答案 1 :(得分:0)

你可以上传截图吗?

Safari,Firefox,Chrome和IE批准您的代码。

enter image description here

这是一个截图。

答案 2 :(得分:0)

更新后工作正常。如果您有徽标相关问题,请复制并粘贴以下代码,而不是之前的代码!

            <div id="youtubelogo">

            <a href="http://www.youtube.com" target="_blank">
            <img src="images/youtubelogo.gif" alt="" width="90" height="50" align="middle">
            </a>
            </div>      

检查图像文件夹中的图像格式,如.gif,.png等 enter image description here