Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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 如何显示以文本为中心且下划线小于h1的h1?_Html_Css - Fatal编程技术网

Html 如何显示以文本为中心且下划线小于h1的h1?

Html 如何显示以文本为中心且下划线小于h1的h1?,html,css,Html,Css,如何显示以文本为中心且下划线小于h1的h1 代码: 我为我的H1标记使用了以下CSS代码,我给了一个类: .referenzen{ display:inline-block; position:center; } .referenzen::after{ content:''; height:2px; width:20%; background:#f24432; position:absolute; left:calc(50% - 10%); bottom:

如何显示以文本为中心且下划线小于h1的h1

代码: 我为我的H1标记使用了以下CSS代码,我给了一个类:

.referenzen{
  display:inline-block;
  position:center; 
}

.referenzen::after{
  content:'';
  height:2px;
  width:20%;
  background:#f24432;
  position:absolute;
  left:calc(50% - 10%);
  bottom:-5px;

}
问题是:H1没有居中


谢谢大家!

您需要使用
位置:相对
文本对齐:居中
position
属性没有
center

.referencen{
显示:内联块;
位置:相对位置;
文本对齐:居中;
左:50%;
转化:translateX(-50%);
}
.referezen::之后{
内容:'';
高度:2倍;
宽度:20%;
背景#f24432;
位置:绝对位置;
左:钙(50%-10%);
底部:-5px;
}

标题
您需要使用
位置:相对
文本对齐:居中
position
属性没有
center

.referencen{
显示:内联块;
位置:相对位置;
文本对齐:居中;
左:50%;
转化:translateX(-50%);
}
.referezen::之后{
内容:'';
高度:2倍;
宽度:20%;
背景#f24432;
位置:绝对位置;
左:钙(50%-10%);
底部:-5px;
}

Title
这里是一个使用flex作为显示的答案,这样您就可以使用justify content来居中显示您的内容,而不是发布其他答案

.referencen{
显示器:flex;
证明内容:中心;
位置:相对位置;
保证金:0自动;
}
.referezen::之后{
内容:'';
高度:2倍;
宽度:20px;
背景#f24432;
位置:绝对位置;
显示器:flex;
证明内容:中心;
底部:-5px;
}

Title
这里是一个使用flex作为显示的答案,这样您就可以使用justify content来居中显示您的内容,而不是发布其他答案

.referencen{
显示器:flex;
证明内容:中心;
位置:相对位置;
保证金:0自动;
}
.referezen::之后{
内容:'';
高度:2倍;
宽度:20px;
背景#f24432;
位置:绝对位置;
显示器:flex;
证明内容:中心;
底部:-5px;
}

标题
位置:中间错误:您可能需要
文本对齐:居中
位置:相对
位置:中心错误:您可能需要
文本对齐:居中
位置:相对谢谢!但是如果我这样使用它,文本仍然不在网页的中间。谢谢!但是如果我像这样使用它,文本仍然不在网页的中间,非常有效,谢谢!非常好用,谢谢!