html - 导航栏图标位置问题

标签 html css

如何设置导航栏文本旁边的图标?

代码:

<ul>
    <li><a href="#" id="other-color" class="ui-btn ui-shadow ui-btn-icon-left ui-custom-icon ui-arrow ui-nodisc-icon">Set Filter</a></li>
    <li><a href="#" id="other-color" class="ui-btn ui-shadow ui-btn-icon-right ui-custom-icon ui-location ui-nodisc-icon">Add Page</a></
</ul>

CSS:

.ui-arrow:after {
    content: '';
    background-image: url(icons/filled-filter-32.png);
    background-size: 15px 15px;
}

.ui-location:after {
    content: '';
    background-image: url(img/plus-32.png);
    background-size: 15px 20px;
}

enter image description here

我需要这样,文本前后不需要空格。

enter image description here

最佳答案

在前面添加图片:

a.ui-arrow{ 
   display: inline-block;
   padding-left: 25px;
}

在之后添加图像:

a.ui-location{ 
   display: inline-block;
   padding-right: 25px;
}

根据您的背景图片管理填充

关于html - 导航栏图标位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24588136/

相关文章:

javascript - 如何从子元素文本值向父元素添加类?查询

html - CSS 水平对齐方式与宽度百分比的关系很奇怪

html - Bootstrap 4 对齐品牌和链接

html - 将元素居中并排放置

php - 获取 wordpress 循环以在第二页上显示帖子

html - css display none 属性不适用于 Internet Explorer 上的 contenteditable div

html - 自动完成 ="off"在 chrome 版本 75.0.3770.142 中不起作用

jquery - 无论悬停位置如何,全宽下拉菜单 Bootstrap

css - 将绝对 div 定位在相对 div 下面

html - 菜单链接旁边的图标 CSS