如何制作这样的对角线?

问题描述 投票:0回答:2

我正在寻找对角线的div,我找不到任何可以帮助我的东西。我有这个项目要做,我需要这样做。

This And This

我想完全这样做,但我只发现水平对角线div的帖子..

感谢和问候。

编辑:第二个图像链接从上面继续。

html image diagonal
2个回答
0
投票

我对对角线div一无所知,但你可以尝试覆盖你需要的部分img

.cover {
position: absolute;
top: -25px; /* or differenet position that fit on every section*/
left: 0;
z-index: 1;
width: 100vw;
height: 50px; /* or different height that you need*/
transform: rotate(-10deg); /* or different angle*/
background-color: white;
}
<div class="cover"></div>
And the same thing on bottom of section.

务必在每个部分设置溢出和位置:

overflow: hidden;
position: relative;

4
投票

在互联网上尝试这个最简单的解决方案来制作多边形

您可以使用CSS属性clip_path生成任何类型的形状。

-webkit-clip-path:polygon(0 33%,100%10%,100%60%,0 85%);该线表示我们绘制的多边形有四个点,并根据x和y指定每个点的位置。您可以根据px, %或任何单位术语指定位置

CSS Code
#header{
background-color:green;
height:350px;
width:100%;
-webkit-clip-path: polygon(0 33%,100% 10%,100% 60%,0 85%);
} 

HTML Code
<html>
<head>

</head>
<body>
<div id="header">

</div>
</body>
</html>

并查看此链接,我在其中编写了相同的代码,仅用于说明剪辑路径功能,以及jsfiddle https://jsfiddle.net/n1y4et70/6/

For further and details Explanation check these links:
https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path
https://css-tricks.com/almanac/properties/c/clip/

如果你不明白,请告诉我。我很乐意帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.