html - 使用线性渐变将顶部切角移动到底部
问题描述
早上好,
我需要以下附加图片的帮助:
使用线性渐变如何将顶角移动到底角并使顶角像其他角一样方/锐利。请参阅下面的当前 css:
body.page {
background: url(../img/Login-bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
font-size: 14px;
align-items: center;
padding-top: 50px;
padding-bottom: 50px;
}
.cut-corner {
position: relative;
color: #4a4a4c;
background-repeat: no-repeat;
background-image: linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431),
linear-gradient(to bottom left, transparent calc(50% - 0.5px), #bcd431 calc(50% - 0.5px), #bcd431 calc(50% + 0.5px), transparent calc(50% + 0.5px)), linear-gradient(transparent, transparent), linear-gradient(transparent, transparent);
background-size: 1.5px 100%, 1.5px 100%, 100% 1.5px, 100% 1.5px, 65px 65px, 100% 100%, 100% 100%;
background-position: 0% 0%, 100% 65px, -65px 0%, 0px 100%, 100% 0%, -65px 0%, 100% 65px;
margin: 25px;
}
.cut-corner:after {
content: "";
position: absolute;
left: 0;
bottom: 0;
right: 0;
top: 0;
z-index: -1;
opacity: 100%;
background-repeat: no-repeat;
background-image: linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431), linear-gradient(#bcd431, #bcd431),
linear-gradient(to bottom left, transparent calc(50% - 0.5px), #bcd431 calc(50% - 0.5px), #bcd431 calc(50% + 0.5px), transparent calc(50% + 0.5px)), linear-gradient(transparent, transparent), linear-gradient(transparent, transparent);
background-size: 0.5px 100%, 1.5px 100%, 100% 0.5px, 100% 1.5px, 65px 65px, 100% 100%, 100% 100%;
background-position: 0% 0%, 100% 65px, -65px 0%, 0px 100%, 100% 0%, -65px 0%, 100% 65px;
}
HTML:
<body class="page cut-corner">
...
</body>
任何帮助将不胜感激。
解决方案
您可以尝试如下,渐变的组合,clip-path
更容易处理
.box {
margin:10px;
height:200px;
border: 2px solid red;
background:
linear-gradient(to bottom right,transparent 50%,red 50.5%)
bottom right/50px 50px no-repeat;
clip-path:polygon(0 0,100% 0,100% calc(100% - 50px),calc(100% - 50px) 100%, 0 100%);
}
body {
background:yellow;
}
<div class="box"></div>
使用 CSS 变量轻松调整角落:
.box {
--c:50px;
margin:10px;
height:200px;
border: 2px solid red;
background:
linear-gradient(to bottom right,transparent 50%,red 50.5%)
bottom right/var(--c) var(--c) no-repeat;
clip-path:polygon(0 0,100% 0,100% calc(100% - var(--c)),calc(100% - var(--c)) 100%, 0 100%);
}
body {
background:yellow;
}
<div class="box"></div>
<div class="box" style="--c:100px;"></div>
推荐阅读
- html - 我可以在 pre 旁边放置一个按钮吗?
- python - Python openpyxl 使用 sheet.row_dimensions[2].fill 出现意外结果
- ionic-framework - 在 Slick Grid 内联编辑中,我无法获取整个对象
- reporting-services - SSRS 并排显示显示表组
- c++ - 如何在 Qt 中使用来自 64 位应用程序的 32 位 COM 对象?
- java - 如何使用AspectJ在java中实现重试机制
- javascript - 在 javascript ('dbo.index') 中通过 mssql 从 SQL Server 读取特定表的问题
- mysql - 根据另一列的更新更新具有自动增量 ID 的列
- arrays - 从文件中读取数组
- cng - 将 SignerSignEx2 与 CNG 提供程序一起使用