html - 居中 ul 的自定义元素符号

标签 html css html-lists

如何水平排列 ul-List 的元素符号?它们就像在底部,我想把它们放在中间。
enter image description here

我使用的元素符号是 SVG。

我搜索了整个网络,但没有找到任何东西。


编辑 1:

这是我的代码(不多,但无论如何):

ul {
    list-style-image: url('newBullet.svg');
  }

编辑 2: 在这段代码之后:

li {
  list-style-type: none;
  background-image: url('http://www.w3schools.com/css/sqpurple.gif');
  background-repeat: no-repeat;
  background-position-y: 12px;

  padding-left: 20px;
}

它看起来像这样,当 li 元素中的文本为 2 行时(它位于两行的中间):

enter image description here

最佳答案

您可以使用背景图片并正确定位,而不是使用列表样式。像这样:

li {
  list-style-type: none;
  background-image: url('newBullet.svg');
  background-repeat: no-repeat;
  background-position-y: center;

  padding-left: 20px;
}

示例:https://jsfiddle.net/o2wyj5ey/

多行

如果您的列表项有多行,您绝对可以这样定位它们:

li {
  list-style-type: none;
  background-image: url('http://www.w3schools.com/css/sqpurple.gif');
  background-repeat: no-repeat;
  background-position-y: 3px;

  padding-left: 20px;
}

示例:https://jsfiddle.net/o2wyj5ey/1/

关于html - 居中 ul 的自定义元素符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42117845/

相关文章:

javascript - 通过选择列表更改的按钮 href 将无法解析(javascript :window. open(window.variable))

html - 我想在小屏幕上使用 google adsense 横幅调整我的段落

html - 水平滚动 div 的垂直居中

html - ios cordova - 使用垂直和水平滚动时的滚动问题

javascript - 如何设置限制th :each loop in HTML

ipad - 多种分辨率的 CSS 媒体查询

jquery - 用于在宽屏幕上折叠 Bootstrap 侧边栏的按钮

html - 定位 UL LI 选择框

jquery - jquery如何插入li

sorting - 具有许多已定义子集的有序集合的数据结构;按相同顺序检索子集