简体   繁体   English

如何在div中垂直一一对齐文本?

[英]How to align text one by one vertically in div?

I need to create a fixed menu button which would be assigned to the right side of the browser. 我需要创建一个固定的菜单按钮,该按钮将分配给浏览器的右侧。 Currently i my code looks lie this: 目前,我的代码看起来像这样:

#button-side-menu {
    background: none repeat scroll 0 0 #F5F5F5;
    border-radius: 5px 5px 0 0;
    color: #363636;
    height: 28px;
    position: fixed;
    right: 16px;
    top: 91px;
    z-index: 2000;
    -moz-transform: rotate(270deg);
    -o-transform: rotate(270deg);
    -webkit-transform: rotate(-90deg);
    -moz-transform-origin: 100% 100%;
    -o-transform-origin: 100% 100%;
    -webkit-transform-origin: 100% 100%;
    padding: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

在此处输入图片说明

Is it possible to center it in the div, the text was not adhered to the right side. 是否可以在div中居中,文字未粘贴在右侧。 And also is it possible to set test like this: 也可以像这样设置测试:

M
e
n
u

PS Site is multilingual so i need the text, not image in this case. PS网站是多语言的,因此在这种情况下,我需要文本而不是图像。

This works: 这有效:

#button-side-menu {
    background: none repeat scroll 0 0 #F5F5F5;
    border-radius: 5px 5px 0 0;
    color: #363636;
    width: 15px;
    position: fixed;
    right: 16px;
    top: 91px;
    z-index: 2000;
    word-wrap:break-word;
    text-align: center;
    padding: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

Important: word-wrap and text-align are added to make it look like what you asked. 重要事项:添加了自动换行和文本对齐功能,使其看起来像您所要求的。 Its width is fixed to 15px instead of height. 它的宽度固定为15px而不是高度。

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

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