简体   繁体   English

如何使用使用html代码生成的文本设置文本样式

[英]How to style the text with text generated using html codes

↑ 2.1 ↑2.1

<span>&#8593; 2.1</span>

The above line was a combination of html symbol and regular text. 上一行是html符号和常规文本的组合。 If I would like to align them with the same height, how would I do it? 如果我想将它们对齐到相同的高度,我该怎么做? Here is the jsfiddle. 这是jsfiddle。 Thanks! 谢谢!
http://jsfiddle.net/RnaKb/ http://jsfiddle.net/RnaKb/

You could use the css :before pseudo-selector, converting #8593 to \\2191. 您可以使用css :before伪选择器,将#8593转换为\\ 2191。 You can then fiddle with the css for this content: 然后,您可以摆弄CSS来获取此内容:

<span> 2.1</span>

span:before {
    content:'\2191';
    vertical-align: text-bottom;
}

This is not exactly the same height currently (looks good though!), but could be with a little fiddling. 目前这高度不完全相同(虽然看起来不错!),但可能有些摆弄。 But you would also have to test in different browsers. 但是您还必须在不同的浏览器中进行测试。

They are already accessible from within the <span> element. 已经可以从<span>元素中访问它们。

Take a look at the jsFiddle where i just added a little .css 看一下我刚刚添加了一点.css的jsFiddle

span {
    font-size:24px;
    line-height:27px;
    vertical-align:baseline;
    border-bottom:1px solid red;
    background-color:#eef;
}

But i understand you think the ↑ arrow symbol is styled differently, but it is not. 但我了解您认为↑箭头符号的样式不同,但事实并非如此。 It was drawn that way. 是这样画的。 So if you want it vertically aligned to bottom, you will have to enclose it in some individual container witch you will have to work with. 因此,如果您希望它与底部垂直对齐,则必须将其封装在必须使用的单个容器中。

<span><span class="your-class-to-ajust-bottom">&#8593;</span> 2.1</span>

Here is a working example : jsFiddled here 这是一个工作示例: jsFiddled here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM