简体   繁体   English

如何对齐文本垂直CSS

[英]How to align text vertical CSS

I'm coding a simple portfolio. 我正在编写一个简单的投资组合。 I'm software developer so I don't have enough knowledge in CSS. 我是软件开发人员,所以我对CSS没有足够的了解。 I want to align text vertical in a row. 我想将文本垂直对齐。 Example of what I want to do is bellow. 我想做的例子是波纹管。

Some Text 1 一些文字1
Some Text 2 一些文字2
Some Text 3 一些文字3

This is what I actually have at the moment. 这就是我目前的实际状况。

Some Text 1
    Some Text 2
   Some Text 3

As you can see, I want to remove that empty space (blanko). 如您所见,我要删除该空白空间(空白)。 I use <p> tag (paragraph) that I styled in CSS. 我使用在CSS中设置样式的<p>标记(段落)。

p { 
    display: inline;
    color: #888;
    position: relative;
    text-shadow: 0 1px 0 rgba(255,255,255, 0.8);
    text-align: center;
    padding: 8px 30px;
    font-family: helvetica, arial, sans-serif;
    display: inline-block;
    vertical-align:middle;
}

If you still don't understand the question, I posted a picture bellow. 如果您仍然不明白这个问题,我在下面贴了一张图片。 The first panel display what I have currently, and the second one, what I want to make. 第一个面板显示我当前拥有的内容,第二个面板显示我想要的内容。 Please note that the second panel is designed. 请注意,第二个面板是设计好的。

It appears that your image sizes are causing the offsets. 看来您的图像尺寸导致了偏移。 If you can get all of those to be the same width, it should line up. 如果可以将所有宽度都设置为相同,则应对齐。

The two options I can think of off the top of my head are: 我可以想到的两个选择是:

  1. The quick and dirty - use a table. 快速又脏-使用桌子。 If you're going for a design job, this will usually get you passed over though. 如果您要从事设计工作,那通常会让您顺利通过。

  2. Use two divs, set their widths, and in the first one use something similar to an unordered list - this will be for your images and whatever is to the right of the image. 使用两个div,设置其宽度,在第一个中使用类似于无序列表的内容-这将用于您的图像以及图像右侧的任何内容。 In the second one you put the text. 在第二个中,您输入了文本。 These columns you would want to set position: relative, float: left, display: inline-block 您想设置位置的这些列:相对,浮动:左,显示:内嵌块

What this will accomplish is that your images will be in their own 'box' and aligned to that box. 这将完成的工作是图像将位于其自己的“框”中并与该框对齐。 And your text will be in its own 'box' and aligned to that box. 您的文本将在其自己的“框”中并与该框对齐。 The boxes edges won't overlap, so you won't have to worry about variable widths among the individual items. 盒子的边缘不会重叠,因此您不必担心各个项目之间的宽度可变。 With a border: 0 on the columns, it will have the visual feel of being altogether. 带有边框:列上为0,将具有整体的视觉效果。

i think this is what you need : 我认为这是您需要的:

css 的CSS

p {
   vertical-align:middle;
}

here the description of the vertical align on w3schools.com http://www.w3schools.com/cssref/pr_pos_vertical-align.asp 此处是w3schools.com http://www.w3schools.com/cssref/pr_pos_vertical-align.asp上垂直对齐的说明

即使它不是最漂亮的,也可以将其TAB插入。

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

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