Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

html - CSS Shape for Div mentioned in the Image

I have 2 images of CSS Div Shape. I want to make my DIVs like in the image.

image

Image 2

Any help would be great.

.imageOne {
  clip-path: polygon(0 0, 100% 0%, 100% 11%, 0 0);
  height: 100px;
  background: blue;
}

.imageTwo {
  clip-path: polygon(80% 30%, 100% 41%, 100% 41%, 0 40%, 0 40%);
  height: 100px;
  background: blue;
}
<div class="imageOne">

</div>


<div class="imageTwo">

</div>
question from:https://stackoverflow.com/questions/65857572/css-shape-for-div-mentioned-in-the-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can adjust the like below:

.imageOne {
  clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 40%); /* adjust the 40% here */
  height: 100px;
  background: 
    linear-gradient(to bottom left,transparent 49%,#b3e1ff 50%) 
     bottom left/200% 60% /* adjust the 200% here, 60% = 100% - 40% (from the top) */
     no-repeat
    #e1f4ff;
}

.imageTwo {
  /*                       here ----v               v---- and here the same */
  clip-path: polygon(100% 100%,100% 70%,  80% 0, 0 70%,0 100%);
  /*    adjust this to control the top ----^                                */
  height: 100px;
  background: #e1f4ff;
}
<div class="imageOne">

</div>


<div class="imageTwo">

</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...