简体   繁体   English

如何垂直对齐文本

[英]How to align text vertically

i have a text inside the <aside></aside> tag and now it is appearing like this 我在<aside></aside>标记内有一个文本,现在看起来像这样

This is the text in <aside>

I want to make it look vertical like this 我想使它看起来像这样垂直

T
h
i
s

i
s

t
h
e

t
e
x
t 

i am using this css 我正在使用此CSS

code: 码:

aside {
    background: none repeat scroll 0 0 #475E80;
    height: 690px;
    position: relative;
    width: 20px;
    text-align:bottom;
}

How can i do this? 我怎样才能做到这一点?

This is a trick 这是一个把戏

aside {
    width: 1px;
    word-break: break-all;
}

Demo: http://jsfiddle.net/zu8QQ/ 演示: http//jsfiddle.net/zu8QQ/

You can wrap your aside with a div if this code messed up your design. 你可以用你的aside有一个div如果这个代码搞砸了你的设计。

Try adding word-wrap property. 尝试添加word-wrap属性。 Your CSS should look like this: 您的CSS应该如下所示:

aside {
    background: none repeat scroll 0 0 #475E80;
    height: 690px;
    position: relative;
    width: 0;
    word-wrap: break-word;
}

Here's an example: http://jsfiddle.net/CkAFs/1/ 这是一个示例: http : //jsfiddle.net/CkAFs/1/

You could also use word-break: break-all but the above solution is slightly better supported by the browsers. 你也可以使用word-break: break-all ,但上述方案在浏览器稍微更好的支持。 Here's the reference: http://caniuse.com/#search=word- (notice that overflow-wrap property is the alias for word-wrap ). 这是参考: http : //caniuse.com/#search=word- (注意, overflow-wrap属性是word-wrap的别名)。

You have many tricks on this link http://net.tutsplus.com/tutorials/html-css-techniques/the-easiest-way-to-create-vertical-text-with-css/ 您可以在此链接上获得许多技巧http://net.tutsplus.com/tutorials/html-css-techniques/the-easiest-way-to-create-vertical-text-with-css/

The important in this example is word-wrap: break-word; 在此示例中,重要的是word-wrap: break-word;

Allow long words to be able to break and wrap onto the next line. 允许长的单词能够折断并换行到下一行。 However, word-wrap: break-word is part of the CSS3 specification, and is not compliant across all browsers. 但是,自动换行:断行是CSS3规范的一部分,并非在所有浏览器中都兼容。

aside {  
    width: 20px;  
    font-size: 50px;  
    word-wrap: break-word;  
}  

jsFiddle here jsFiddle在这里

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

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