html - Unicode 字符对齐

标签 html css unicode

我想在按钮中心显示一个 unicode 字符,参见

<div class="col-xs-1">
    <button class="btn btn-tool">
      <span></span>
    </button>
  </div>

span:before {
  font-family: "Arial Unicode MS";
  content: "\25cf";
  font-size: 3em;
  vertical-align: middle;
}

如所述here ,我尝试使用

调整字符大小

font-size

vertical-align.

JSFiddle中可以看出, 对齐方式不理想(字符水平和垂直居中)。 你能帮忙吗?

最佳答案

您有多种方法可用于水平和垂直居中。这是我想要的:

.btn.btn-tool {
  position: relative;
  height: 200px; /* inserted height and width only for demonstration purposes */
  width: 80px;
}
span:before {
  font-family: "Arial Unicode MS";
  content: "\25cf";
  font-size: 3em;
  display: block;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  width: 100%;
}
<button class="btn btn-tool">
  <span></span>
</button>

https://jsfiddle.net/g8skps53/8/

关于html - Unicode 字符对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39815922/

相关文章:

html - 调整视口(viewport)大小后,Firefox 和 Chrome 中的 div 宽度变化不同

javascript - 如何使用 id 从 html 调用 javascript

Python UNICODE csv 阅读器 GZIPPED 文件

javascript - Bootstrap 字形图标编辑未显示

css - 如何使按钮值不可见并向按钮添加图像

javascript - 如何使用 jQuery UI 中的 Draggable 和 Droppable 将拖动的 li 附加到可放置的 ui 中?

python 2、3、os.environ 和 unicode

python 2.7 : 'Ramón' == u'Ramón'

html - 如何使用 CSS(在文本上)应用适当的渐变 alpha 蒙版?

html - 使 <td> 尽可能宽