Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css div内文本的精确垂直对齐_Css - Fatal编程技术网

Css div内文本的精确垂直对齐

Css div内文本的精确垂直对齐,css,Css,是否可以将单行文本元素放置在div中,使其基线精确地与div的底边重合。就像在svg rect中一样。我可以手动操作,但对于任何字体大小都可以使用通用方法。可能是用“em”单位测量的位移 现在,我执行类似的操作来对齐两个div('name'和'start')中的文本,字体大小不同,水平对齐也不同,我希望它们能够垂直精确对齐,而不是通过手动调整底部边距: .project-div .footer { position: absolute; bottom: 0px; height: 2

是否可以将单行文本元素放置在div中,使其基线精确地与div的底边重合。就像在svg rect中一样。我可以手动操作,但对于任何字体大小都可以使用通用方法。可能是用“em”单位测量的位移

现在,我执行类似的操作来对齐两个div('name'和'start')中的文本,字体大小不同,水平对齐也不同,我希望它们能够垂直精确对齐,而不是通过手动调整底部边距:

.project-div .footer {
  position: absolute;
  bottom: 0px;

  height: 28px;
  width: 100%;

  display: inline-block;
  line-height: 28px;
}

.project-div .footer .name {
  position: absolute;
  left: -1px;
  bottom: -20%;

  line-height: 28px;
  font-size: 28px;
  height: 28px;
}

.project-div .footer .start {
  position: absolute;
  right: -3px;
  bottom: -10%;

  line-height: 18px;
  font-size: 18px;
  height: 18px;

  font-family: "Arial Black";
  color: #ccc;
}

我会说,如果您希望将属性
position:relative
分配给您的家长,然后将属性
position:absolute
bottom:0
分配给您的孩子,使其完全位于家长div的底部


下次再详细解释一下你的问题。

你的尝试在哪里?我会将两个div的底线对齐,但我想对齐基线,它们在不同字体大小的不同高度。你介意发布一个你目前拥有的屏幕截图吗?试着看看这篇文章的截图:“时间线”和“2012”是手动对齐的,但并不精确。谢谢链接,我稍后再试