Home > Web Front-end > HTML Tutorial > How to achieve vertical text effect with CSS

How to achieve vertical text effect with CSS

PHP中文网
Release: 2017-06-05 14:33:25
Original
3327 people have browsed it

CSS如何实现文字竖排效果:
文字竖排虽然不常用,但是并不是没有这方面的需求,但是现有的CSS属性支持度都不高或者兼容性不好,确实没有找到合适的方法来实现此效果,下面就分享一个用javascript实现的效果,大家可以借鉴一下,效果非常的好。代码实例如下:

<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> 
<meta name="author" content="www.51texiao.cn/" /> 
<title>蚂蚁部落</title> <style type="text/css">
 span{   float:right;   width:1em;   text-align:center;   word-wrap:break-word;   background:#ccf;   margin:0 5px; } </style> <script type="text/javascript">
 function shuPai(eid){   var p = document.getElementById(eid);   var str=p.innerHTML.replace(/<[^>]+>/gi,"");   var arr = str.replace(/(.{1,10})/g,"<span>$1</span>");  
 p.innerHTML = arr; } window.onload=function(){shuPai("test");} </script> </head> <body>  
 <p id="test">文字竖排虽然不常用,但是并不是没有这方面的需求,但是现有的CSS属性支持度都不高或者兼容性不好。
</p> 
</body> 
</html>
Copy after login

以上代码完美的实现了想要的效果,可以直接套用就可以了,如果感谢兴趣可以自行分析一下代码。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template