悬停过渡不起作用

时间:2012-11-12 22:55:43

标签: javascript html css

这是我的jsfiddle代码 http://jsfiddle.net/jspence29/VqZSw/ 但似乎它不起作用所以我会给你我的代码

#links ul

{
  margin-left: auto;
  position: fixed;
  margin-right: auto;
}

#links ul li

{
  margin-left: 200px;
  font-family: sans-serif:
  background-color: #fff;
  display: inline;
  width: 25px;
}

#links ul li a 

{
  background-color: #fff;
  opacity: 0.8;
  filter: alpha(opacity=80);
  color: #ffffff;
  text-align: center;
  width: 25px;
  padding: 10px;
  font-family: sans-serif;
  text-decoration: none;
  position: relative;
  top: 180px;
  overflow: hidden;
  transition:width .5s;
  -moz-transition:width .5s; /* Firefox 4 */
  -webkit-transition:width .5s; /* Safari and Chrome */
  -o-transition:width .5s; /* Opera */
}

#links ul li a:hover

{
  color: #000;
  width: 50px;
}
</style>

<head>
<body>


<div id="background" >
<div id="menuButton" onclick="showMenu()" >
<p><span style="cursor:pointer">Menu </span></p>
</div>
<div id="menu" style="display: none;">
<h1> Singapore </h1>
<p>ever onward, singapore </p>
<ul>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" > Gallery <span class="show"> 
Click to see pictures of the most elegant city in the world </span> </a> </li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" > Tour <span class="show">
Click to take a tour of the one of a kind singapore</span> </a> </li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" > Facts <span class="show"> 
Click to learn astounding facts of the one and only singapore</span> </a> </li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" > Author <span class="show"> 
Click to learn about me, and see my works cited page </span></a> </li>
</ul>
</div><!--Menu-->
<div id="links" >
<ul>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" >  Gallery </a></li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" > Tour </a></li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" >  Facts </a></li>
<li> <a href="http://www.spencedesign.netau.net/singapore.html" >  Author </a></li>
</ul>
</div>
</div><!--Background-->



</body>
</html>

指向我的信息页http://www.spencedesign.netau.net/singaporehomemenu.html

的链接

所以,我的问题是当你将鼠标悬停在顶部的按钮上时,宽度会发生变化。但是当您在底部链接上执行此操作时,它不会。它应该改变,因为我使用了相对相同的代码。所以我不知道问题是什么。我已经把代码搞砸了大约半个小时,但找不到修复程序。我知道我的CSS / HTML编码是粗鲁的,但我是初学者,我认为我通过你学习的越多,我就会越好。感谢您的时间,如果您看过我的其他帖子,我很抱歉发布这么多,我想您可以说我在我的网站计划中已经超出了我的想法。

2 个答案:

答案 0 :(得分:1)

过渡效果很好。但是,A元素是内联元素。宽度被忽略。添加display: block;即可。

答案 1 :(得分:0)

你在哪里:

 #links ul li a:hover

如果您还添加了...

,它是否有效
 #links ul a:hover

当然具有相同的造型。

相关问题