Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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/1/typo3/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:在涉及图像的问题之前_Html_Css_Pseudo Element - Fatal编程技术网

Html H1:在涉及图像的问题之前

Html H1:在涉及图像的问题之前,html,css,pseudo-element,Html,Css,Pseudo Element,我试图制作一个css标题,看起来像这样 我有一个带有透明度的png三角形,但我以前没有真正使用过伪元素,所以如果有人能帮忙的话,那就太棒了 到目前为止,我得到了这个: h1 {text-transform: uppercase;font-weight: 600; margin: 0; padding: 0;} h1:before { content: url( "../images/triangle.png" ) ; margin-right: -50px;} 这将正确地水平放置文本,但我找不

我试图制作一个css标题,看起来像这样

我有一个带有透明度的png三角形,但我以前没有真正使用过伪元素,所以如果有人能帮忙的话,那就太棒了

到目前为止,我得到了这个:

h1 {text-transform: uppercase;font-weight: 600; margin: 0; padding: 0;}
h1:before {
content: url( "../images/triangle.png" ) ;
margin-right: -50px;}

这将正确地水平放置文本,但我找不到一种方法来正确地垂直放置文本

您可以使用下面的css并通过位置管理它:

h1 {
    text-transform: uppercase;
    font-weight: 600;
    margin: 0;
    padding: 0;
    position: relative
}
h1:before {
    content: "";
    position:absolute;
    width: 40px;
    height: 40px;
    background: url( "../images/triangle.png" );
    right: -50px;
    top: 0px;
}

你想让文本垂直吗? 试试这个


您可以这样尝试:

h1 {
    text-transform: uppercase;
    font-weight: 600;
    margin: 0;
    padding: 0;
    position:relative;
    z-index:9999;
    line-height:80px;
    text-indent:20px;
}
h1:before {
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border-top: 100px solid red;
    border-right: 100px solid transparent;
    content:"";
    display:block;
    position:absolute;
    z-index: -1;
    /* to be below the parent element */
}
HTML:

fddfgfdg

请检查小提琴-


要添加背景图像,请删除
h1:before
中的所有边框,并添加图像的宽度和高度

add fiddle,以便我们可以帮助您解决此问题。
h1 {
    text-transform: uppercase;
    font-weight: 600;
    margin: 0;
    padding: 0;
    position:relative;
    z-index:9999;
    line-height:80px;
    text-indent:20px;
}
h1:before {
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border-top: 100px solid red;
    border-right: 100px solid transparent;
    content:"";
    display:block;
    position:absolute;
    z-index: -1;
    /* to be below the parent element */
}
<h1>fddfgfdg</h1>