简体   繁体   English

仅使用CSS格式化文本

[英]Formatting text only with CSS

I run a site where users submit basic news articles. 我在一个网站上向用户提交基本新闻文章。 I want to add some formatting features for their submissions. 我想为其提交添加一些格式设置功能。

Is it possible to add custom formatting to text only using CSS ? 是否可以仅使用CSS向文本添加自定义格式?

For example, user can add: 例如,用户可以添加:

**This should be bold**

And the text appears bold. 文本显示为粗体。 Or user adds > at the beginning of the paragraph: 或者用户在段落的开头添加>

> This could be a lengthy paragraph

And the paragraph is aligned to the center. 并且该段落与中心对齐。

Is such thing possible to do? 这样的事情有可能吗?

It's not possible using pure CSS. 使用纯CSS是不可能的。 You have to use Javascript or JQuery or process your custom tags in Server-Side and render them as html and css as you want. 您必须使用JavascriptJQuery或在Server-Side处理自定义标签,然后根据需要将它们呈现为html和css。

No it is not. 不它不是。 You will need javascript or php to replace ** with <b> for example. 例如,您将需要javascript或php将<b> ** <b>替换为** Otherwise your users would need to put in <b>Hello</b> 否则,您的用户需要输入<b>Hello</b>

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

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