使用html+JQ+css5 完整代码横版文字转换成竖版 从左到右
<!DOCTYPE html>
<html>
<head>
<title>横版文字转换成竖版</title>
<style type="text/css">
.wrapper {
width: 100%;
height: 500px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
}
<pre><code> .text {
writing-mode: vertical-rl;
transform: rotate(180deg);
font-size: 24px;
line-height: 30px;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
white-space: nowrap;
}
.text span {
display: inline-block;
}
.text span:before {
content: "";
display: inline-block;
width: 0;
height: 100%;
vertical-align: middle;
}
</style>
</code></pre>
</head>
<body>
<div class="wrapper">
<div class="text">
<span>横版文字转换成竖版</span>
<span>从左到右</span>
</div>
</div>
<pre><code><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var text = $(".text").text();
var chars = text.split("");
$(".text").empty();
$.each(chars, function(index, value){
$(".text").append("<span>" + value + "</span>");
});
});
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/biEC 著作权归作者所有。请勿转载和采集!