2

私は次のcssを持っています

#custom-module .moduletable:nth-child(2) h3 {
    background: url(../images/icon-news.jpg)no-repeat center left;
    position: relative;
}
#custom-module .moduletable:nth-child(2) h3:after{
    background: url(../images/icon-all-news.jpg) no-repeat right center;
    content: url(www.google.com);
    position: absolute;
    width: 22px;
    height: 9px;
    top: 10px;
    right: 0;
}

h3:after background クリック可能にするにはどうすればよいですか?


でラップできないことに注意h3 tagしてくださいa tag


不可能な場合、jquery を使用してこれを href に割り当てるにはどうすればよいですか?

4

1 に答える 1

2

CSS では不可能です。jQuery ソリューションは次のようになります。

var $link = $('<a>',{
    class: 'all-news-link',
    href: 'http://google.com'
});

$('#custom-module .moduletable:nth-child(2) h3').append($link);

次に、CSS を次のように変更します。

#custom-module .moduletable:nth-child(2) h3 .all-news-link{
    background: url(../images/icon-all-news.jpg) no-repeat right center;
    position: absolute;
    width: 22px;
    height: 9px;
    top: 10px;
    right: 0;
}
于 2013-09-08T08:02:40.280 に答える