Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 菜单和标题_Css - Fatal编程技术网

Css 菜单和标题

Css 菜单和标题,css,Css,有一个菜单栏和一个标题。 我希望不同的菜单项更改标题图像 无悬停->默认标题图像 菜单1悬停->更改标题图像1 菜单2悬停->更改标题图像2 菜单3悬停->更改标题图像3 我使用photoshop创建: 对不起,英语很差。。。 我在等待答案您必须将标题图像放在菜单中。然后你可以这样做: .menu1:hover div.header1 { background-image:url(/header2.jpg); } $(document).ready(function () {

有一个菜单栏和一个标题。 我希望不同的菜单项更改标题图像

无悬停->默认标题图像

菜单1悬停->更改标题图像1

菜单2悬停->更改标题图像2

菜单3悬停->更改标题图像3

我使用photoshop创建:

对不起,英语很差。。。
我在等待答案

您必须将标题图像放在菜单中。然后你可以这样做:

.menu1:hover div.header1 {
       background-image:url(/header2.jpg);

 }
$(document).ready(function () {
    // #menu is the id of either the container div or the ul
    $('#menu li').hover(
        function() {
            var index = $('#menu li').index(this);
            //#header is the ID of your header image
            $('#header').attr('src','../imgs/your_image_name'+index+'.jpg');

      },
      function() {
            $('#header').attr('src','../imgs/your_image_name.jpg');
      }
}):

也许可以使用jquery?大概是这样的:

.menu1:hover div.header1 {
       background-image:url(/header2.jpg);

 }
$(document).ready(function () {
    // #menu is the id of either the container div or the ul
    $('#menu li').hover(
        function() {
            var index = $('#menu li').index(this);
            //#header is the ID of your header image
            $('#header').attr('src','../imgs/your_image_name'+index+'.jpg');

      },
      function() {
            $('#header').attr('src','../imgs/your_image_name.jpg');
      }
}):