gpt4 book ai didi

css - 如何三 Angular 形顶部和底部边框?

转载 作者:行者123 更新时间:2023-11-28 09:05:33 25 4
gpt4 key购买 nike

正如您在下图中看到的那样,我试图从底部和顶部扭曲或三 Angular 化我的 div,但我不知道该怎么做。我只是尝试了几次,但我无法达到结果。那么我怎样才能在伪装之前使用它呢?用 psuedo 制作没关系,但我想知道该怎么做?

enter image description here

这是我的代码:

body{
background:lightblue;;
}
.block{
background-image: linear-gradient(to right, #314b56, #283b44, #1f2c32, #161e21, #0a0f11);
border: 1px solid #fff;
width: 300px;
height: 150px;
margin: 30px;
}
<div class="block"></div>

最佳答案

使用转换和透视的想法,您将在其中拥有边框、边框半径和渐变:

body {
background: lightblue;
}

.block {
overflow: hidden;
width: 300px;
height: 200px;
margin: 20px;
position: relative;
z-index:0;
}

.block::before,
.block::after {
content: "";
position: absolute;
z-index:-1;
border: 1px solid #fff;
top: 0;
bottom: 0;
width: 50%;
background-image: linear-gradient(to right, #314b56, #283b44, #1f2c32, #161e21, #0a0f11);
background-size: 200% 100%;
}

.block::before {
left: 0;
border-right: 0;
border-radius: 15px 0 0 15px;
transform-origin: right;
transform: perspective(100px) rotateY(-5deg);
}

.block::after {
right: 0;
border-left: 0;
border-radius: 0 15px 15px 0;
transform-origin: left;
transform: perspective(100px) rotateY(5deg);
background-position: right;
}
<div class="block"></div>

您还可以添加阴影并轻松更改渐变:

body {
background: lightblue;
}

.block {
overflow: hidden;
width: 300px;
height: 200px;
margin: 20px;
position: relative;
z-index:0;
filter:drop-shadow(0 0 5px #000);
}

.block::before,
.block::after {
content: "";
position: absolute;
z-index:-1;
border: 1px solid #fff;
top: 0;
bottom: 0;
width: 50%;
background-image: linear-gradient(35deg, blue, red);
background-size: 200% 100%;
}

.block::before {
left: 0;
border-right: 0;
border-radius: 15px 0 0 15px;
transform-origin: right;
transform: perspective(100px) rotateY(-5deg);
}

.block::after {
right: 0;
border-left: 0;
border-radius: 0 15px 15px 0;
transform-origin: left;
transform: perspective(100px) rotateY(5deg);
background-position: right;
}
<div class="block"></div>

关于css - 如何三 Angular 形顶部和底部边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54555499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com