JSFiddle - React, Tailwind, and code Playground

by tea4two

HTML

<ul id="nav">
    <li><a href="#" class="link">リンク</a>
    </li>
    <li><a href="#" class="link">リンク</a>
    </li>
    <li><a href="#" class="link">リンク</a>
    </li>
</ul>

CSS

#nav {
}
li {
    float: left;
    margin-right: 5px;
    margin-bottom: 5px;
    list-style: none;
}
.link, .link span {
    display: block;
    width: 200px;
    height: 60px;
    text-indent: -9999px;
    background: url(https://dl.dropboxusercontent.com/u/182576/school2013/btn.png) no-repeat 0 0;
}
.link {
    position: relative;
}
.link span {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    background-position: 0 -60px;
    z-index: 2;
}

JavaScript

$('#nav li a').each(function () {
    var _span = $('<span/>');
    $(this).append(_span);
    $(this).hover(function () {
        $(this).find('span').fadeIn();
    },
    function () {
        $(this).find('span').fadeOut();
    });
});