Changing background image when hovering on a list item

前端 未结 4 1979
耶瑟儿~
耶瑟儿~ 2020-12-19 04:37

As you can see in the screenshot, I\'ve got an unordered list. Now the div of this list has a background image. What I want to do is to change background\'s ima

4条回答
  •  孤城傲影
    2020-12-19 04:50

    Since there is still no CSS parent selector you can use jQuery

    #container {
        width: 800px;
        height: 600px;
        background: url(http://filepic.ru/file/1441522670.jpg);
    }
    #container li {
        display: block;
        margin: 5px;
        float: right;
        clear: both;
        background-color: #fff;
        width: 150px;
    }
    #container li:hover {
        background-color: green;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

提交回复
热议问题