我需要在导航元素之间添加分隔符.分隔符是图像.
I need to add separators between elements of navigation. Separators are images.
我的 HTML 结构是这样的:ol >李>一个>img.
My HTML structure is like: ol > li > a > img.
这里我提出了两种可能的解决方案:
Here I come to two possible solutions:
li 标签进行分隔(嘘!),li tags for separation (boo!),怎么办?
只需在li上使用分隔图作为背景图即可.
Simply use the separator image as a background image on the li.
要让它只出现在列表项之间,请将图像放在 li 的左侧,但不要放在第一个.
To get it to only appear in between list items, position the image to the left of the li, but not on the first one.
例如:
#nav li + li {
background:url('seperator.gif') no-repeat top left;
padding-left: 10px
}
此 CSS 将图像添加到跟在另一个列表项之后的每个列表项 - 换句话说,除了第一个之外的所有列表项.
This CSS adds the image to every list item that follows another list item - in other words all of them but the first.
注意.请注意 相邻选择器 (li + li) 在 IE6 中不起作用,因此您只需将背景图像添加到常规 li (使用条件样式表)并可能应用负边距到边缘之一.
NB. Be aware the adjacent selector (li + li) doesn't work in IE6, so you will have to just add the background image to the conventional li (with a conditional stylesheet) and perhaps apply a negative margin to one of the edges.
这篇关于导航分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检查重复的 CSS 规则?How to check for duplicate CSS rules?(如何检查重复的 CSS 规则?)
删除多个文件中的重复 CSS 声明Remove duplicate CSS declarations across multiple files(删除多个文件中的重复 CSS 声明)
Google Drive CSS/JS 返回 404 错误Google Drive CSS/JS Returns 404 Error(Google Drive CSS/JS 返回 404 错误)
在按钮之间添加空间?Adding space between buttons?(在按钮之间添加空间?)
Sencha Touch Ext.navigation.View pop to rootSencha Touch Ext.navigation.View pop to root(Sencha Touch Ext.navigation.View pop to root)
使用 CSS 和单个列表的简单 2 列导航?Simple 2-column navigation with CSS and a single list?(使用 CSS 和单个列表的简单 2 列导航?)