CSS Sprite : An easy way to do a generic unordered list?

标签 css css-sprites

我正在尝试做 CSS Sprites,例如:http://www.alistapart.com/articles/sprites

我的菜单将通过 Wordpress 动态生成。我有 3 种基本状态:始终开启、悬停和事件。这将是所有按钮的相同状态。

我想使用基本的排序不足的列表,例如:

<div class="navigation"> 
<ul>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 1</a></li>
    <li><a href="#">Link 1</a></li>
</ul> 

我见过的每一种技术都在 LI 或 A 状态上使用 ID,是否可以使用上面的基本结构来做到这一点?

最佳答案

没关系,我想通了:

#topNav ul li{
    background:url("images/menu.jpg");
    width:141px;
    float:left;
    height:39px;
    /* padding: 10px 25px 10px 40px; */
    margin:1px;
    background-position:142px 0px;
    display: inline;
}

#topNav ul li:hover{
    background:url("images/menu.jpg");
    width:141px;
    background-position:284px 0px;
}

#topNav ul li .current{
    background:url("images/menu.jpg");
    width:200px;
    background-position:0px 0px;
}

关于CSS Sprite : An easy way to do a generic unordered list?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4999640/

相关文章:

css - GWT 图像 Sprite : how to move the background image to the right side

html - CSS Sprite - 在 <li> 中点击 <a>

css - 在 Chrome 上缩放时,图像 Sprite 变得不对齐

css - 背景图像在生产中的 rails style.css 中不起作用

javascript - 带有选项的简单选择标签不适用于 Chrome

html - 宽度为 % 的 div 中的 Css sprite?

html - 什么时候 CSS Sprite 太大了?

html - @media 查询不适用于 Android 手机 (Chrome)

javascript - 让 DIV 跳出 Bootstrap 4 容器

jquery - 隐藏和显示下拉菜单