Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.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/41.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 :在伪元素未显示之前_Html_Css - Fatal编程技术网

Html :在伪元素未显示之前

Html :在伪元素未显示之前,html,css,Html,Css,我无法获取要显示的:before伪元素。我想在有问题的元素后面创建一个形状 您的CSS中有一个输入错误 div的id是info\u text\u startday,在css中您有\info\u text\u starday:before 因此,在css中替换为 #info_text_startday:before{ position: absolute; content: ''; z-index: 2; background-color: black; border: 3px solid wh

我无法获取要显示的
:before
伪元素。我想在有问题的
元素后面创建一个形状


您的CSS中有一个输入错误

div
id
info\u text\u startday
,在css中您有
\info\u text\u starday:before

因此,在css中替换为

#info_text_startday:before{
position: absolute;
content: '';
z-index: 2;
background-color: black;
border: 3px solid white;
height: 300px;
width: 290px;   
}

看到了吗,谢谢,这很有效。多么愚蠢的错误啊。现在,伪元素显示在我的实际页面上,但它不考虑z-index!这可能是因为你所使用的位置不同。一个是绝对的,另一个是相对的。这是你想要的吗?为有效的
z-index
给出一个负值!So:before的z-index of:before伪元素使用其引用元素作为z-index上下文。我感谢你的帮助!谢谢……:)很高兴它对你有帮助如果它对你有帮助,请你把答案标记为接受。。
#container{
height: auto;
width: 300px;
background-color: red;
}

#info_text_startday_explain{
display: inline-block;
width: 100%;
text-align: center;
margin: 0 auto;
font-size: 2em;
color: black;
}
#info_text_startday{
position: relative;
z-index: 3;
color: white;
font-size: 2.8em;
}

#info_text_starday:before{
position: absolute;
content: '';
z-index: 2;
background-color: black;
border: 3px solid white;
height: 300px;
width: 290px;   
}
#info_text_startday:before{
position: absolute;
content: '';
z-index: 2;
background-color: black;
border: 3px solid white;
height: 300px;
width: 290px;   
}