Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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
Html 如何在div中使span元素位于文本中间_Html_Css - Fatal编程技术网

Html 如何在div中使span元素位于文本中间

Html 如何在div中使span元素位于文本中间,html,css,Html,Css,我有一个类似于贝娄的代码: <div style="font-size:58px;"> Name <span style="font-size:18px; vertical-align:middle;">|</span> 2015-04-01 </div> Name | 2015-04-01 然后我得到了这样的结果 但我希望跨度元素像这样高一点 请教我怎么做,非常感谢。 实际上, SPAN 元素在技术

我有一个类似于贝娄的代码:

<div style="font-size:58px;"> Name <span style="font-size:18px; vertical-align:middle;">|</span> 2015-04-01 </div>
Name | 2015-04-01
然后我得到了这样的结果

但我希望跨度元素像这样高一点


请教我怎么做,非常感谢。

实际上,<代码> SPAN <代码>元素在技术上已经在中间了。您可以通过应用

vertical align:top
垂直对齐:底部
垂直对齐:中间
span
元素上

除此之外,我建议使用

position:relative;
top:-.5em;
span
上。使用
em
单位使其依赖于字体大小(尽管这并不完美,因为它依赖于
span
元素的字体大小)

演示:


Name | 2015-04-01
您的代码运行得非常好。非常感谢:)