【问题标题】:CSS hover Not working in Google Chrome when running the file using a server使用服务器运行文件时,CSS悬停在谷歌浏览器中不起作用
【发布时间】:2015-02-02 03:09:04
【问题描述】:

当我在 wamp 服务器中运行我的 html 文件时,悬停 css 功能在 google chrome 上不起作用。我在 Internet Explorer 中尝试过,然后它工作正常。当我在不使用服务器的情况下打开文件时,它在 chrome 中运行良好。只有当我使用服务器运行它时才会发生。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<title></title>

<link href="CSS/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a href="http://localhost/voted.php?vote=1"><div class="vote1"></div></a>

</body>
</html>

这是我的css文件

vote1:hover a{
width: 50px; 
height: 50px;
border-style: solid;
border-color: Black;
background: url('H:/Site/haride/Images/x.jpg')repeat-x right top;
}
 .vote1 {
display: block;
box-sizing: border-box;
width: 50px;
height: 50px;
float: left;
position: absolute;
top: 450px;
left: 148px;
border-style: solid;
border-color: Black;
}

【问题讨论】:

  • 您使用的是本地路径 'H:/Site/haride/Images/x.jpg'

标签: html css google-chrome hover


【解决方案1】:

您的 CSS 具有指向磁盘上文件的硬链接:

background: url('H:/Site/haride/Images/x.jpg')repeat-x right top;

删除 h:/Site/haride 并在您的网站项目中创建一个 Images 文件夹并将 x.jpg 文件复制到该文件夹​​。

并非所有访问您网站的人都可以访问 H:/Site,但他们可以访问子文件夹 /Images

【讨论】:

    【解决方案2】:

    您的 CSS 结构不正确。悬停链接的正确语法是

    a div.vote1:hover {
    

    JSFiddle - http://jsfiddle.net/L44fwpv7/

    正如其他人提到的那样,您调用本地文件。

    【讨论】:

      猜你喜欢
      • 2016-05-07
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 2011-12-04
      • 2015-11-18
      • 2011-02-15
      • 2020-04-11
      相关资源
      最近更新 更多