Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.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 如何添加伪元素渐变效果_Css - Fatal编程技术网

Css 如何添加伪元素渐变效果

Css 如何添加伪元素渐变效果,css,Css,您好,我如何添加从左到右的伪元素渐变效果。 我正在努力: .divider p:after { content: ""; position: absolute; top: 50%; left: 0; right: 25%; z-index: -1; border-top: 1px solid #666666; } HTML 针对伯格曼对原始答案的提问: 你可以用一些额外的css来模拟立体渐变边框 HTML: 在本示例中,.element

您好,我如何添加从左到右的伪元素渐变效果。 我正在努力:

.divider p:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 25%;
    z-index: -1;
    border-top: 1px solid #666666;
}
HTML


针对伯格曼对原始答案的提问:

你可以用一些额外的css来模拟立体渐变边框

HTML:


在本示例中,.element填充用于模拟边框。

您可能想澄清“伪元素渐变效果”的含义。它绘制了一条形状线,但我希望它是这样的渐变。它绘制了一条锐利的线,因为有一个边框应用于带有
位置:绝对的行为类似于块元素。因此,您可以不使用
display:block
.box:before,
.box:after {
  content: "";
  position: absolute;
  display: block;
  left: -10px;
  width: 1px;
  height: 50%;
}

.box:before {
  top: 0;
  background: linear-gradient(to top, #333 0%, transparent 100%);
}

.box:after {
  bottom: 0;
  background: linear-gradient(to bottom, #333 0%, transparent 100%);
}
.divider {
color: #666666;
}
.divider p span {
margin:0;padding: 0 10px;
background: #FFFFFF;
display: inline-block;
}
.divider p {
padding-left: 20px;
position: relative;
z-index: 2;   
}
.divider p:after {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 25%;
z-index: -1;
border-top: 1px solid #666666;
}
<div class="element">
    <div class="content">
        Content
    </div>
</div>
.element {
    position: relative;
    padding: 5px;
}
.element:before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 100%;
    background-image: linear-gradient(90deg, #000 0%, #fff 100%);
}
.content {
    position: relative;
    background-color:white;
}
.box:before,
.box:after {
  content: "";
  position: absolute;
  display: block;
  left: -10px;
  width: 1px;
  height: 50%;
}

.box:before {
  top: 0;
  background: linear-gradient(to top, #333 0%, transparent 100%);
}

.box:after {
  bottom: 0;
  background: linear-gradient(to bottom, #333 0%, transparent 100%);
}