dongzi1397 2012-06-04 16:00
浏览 54

内联悬停在Div上

Hi I am trying to run a while loop from a database to display a number of different records, however the way the record is displayed is through different images, therefore I cannot customize it using standard css and am doing it through inline css, however I have got it to the point where it displays each image fine, however won't display the new image on hover by the user, here is the line for the div concerned

<div id="house_wrapper" style="background-image: url(images/HOUSES/<?php print "$house_name";?>.png); :hover{background-image: url(images/HOUSES/<?php print "$house_name";?>_hover.png)};"></div><!---end house_wrapper--->

And here is the code for the entire while loop

    <div id="house_summary_content">

  <?php 
          $query = mysql_query("SELECT * FROM user_houses WHERE user_id='$user_id'");

          while($row = mysql_fetch_assoc($query)) : ?>
<?php extract($row);?>
<?php $sql_house = mysql_query("SELECT * FROM houses WHERE house_id='$house_id'");
$house_array = mysql_fetch_assoc($sql_house);
$house_name = $house_array['house_name'];?>
<div id="house_wrapper" style="background-image: url(images/HOUSES/<?php print "$house_name";?>.png); :hover{background-image: url(images/HOUSES/<?php print "$house_name";?>_hover.png)};"></div><!---end house_wrapper--->


 <?php endwhile ?>

</div><!---end house_summary_content--->

Thanks for any help you guys can give

  • 写回答

2条回答 默认 最新

  • douwen1915 2012-06-04 17:40
    关注

    Could you possibly use javascript through onmouseover and onmouseout? for example:

    <div id="house_wrapper" style="background-image: url(http://i.imgur.com/F5iJY.jpg);width:100%;height:400px;" onmouseover="this.style.backgroundImage='url(http://i.imgur.com/YpJyG.jpg)';" onmouseout="this.style.backgroundImage='url(http://i.imgur.com/F5iJY.jpg)';"></div>​
    

    Demo http://jsfiddle.net/UvPHp/9/

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题