My current design uses clip-path
for a gradient effect at the top of the page. Ideally, I want the two angles to meet seamlessly without any visual issues.
I initially positioned the top so that they touch perfectly and nothing interferes with the angled content. Specifically, I used top: -120px;
but later switched to margin-top: -120px;
. The change looks good and the positioning seems acceptable, but I'm open to suggestions for improvement.
The problem arises when the content gets stuck underneath as shown below:
.site-hero-colour {
min-width: 100%;
max-width: 100%;
min-height: 600px;
max-height: 600px;
background: linear-gradient(-45deg, #FFFFFF, #000000);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 80%);
margin: 0;
padding: 0;
position: relative;
}
@media only screen and (max-width: 500px) {
.site-hero-colour {
min-width: 100%;
max-width: 100%;
min-height: 400px;
max-height: 400px;
background: linear-gradient(-45deg, #FFFFFF, #000000);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 90%);
margin: 0;
padding: 0;
position: relative;
}
}
.site-hero-content {
min-width: 100%;
min-height: 160px;
background: #FFFFFF;
clip-path: polygon(0 0, 100% 20%, 100% 100%, 0 100%);
position: relative;
margin-top: -120px;
margin: 0;
padding: 0;
}
@media only screen and (max-width: 500px) {
.site-hero-content {
min-width: 100%;
min-height: 160px;
background: #FFFFFF;
clip-path: polygon(0 0, 100% 10%, 100% 100%, 0 100%);
position: relative;
margin-top: -40px;
margin: 0;
padding: 0;
}
}
<div class="site-hero-colour"></div>
<div class="site-hero-content">
<h1>The content is getting cut off. It should overlay the white space or align perfectly.</h1>
</div>
One alternative solution could be like this:
.site-hero-colour {
min-width: 100%;
max-width: 100%;
min-height: 600px;
max-height: 600px;
background: linear-gradient(-45deg, #FFFFFF, #000000);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 80%);
margin: 0;
padding: 0;
position: relative;
}
@media only screen and (max-width: 500px) {
.site-hero-colour {
min-width: 100%;
max-width: 100%;
min-height: 400px;
max-height: 400px;
background: linear-gradient(-45deg, #FFFFFF, #000000);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 90%);
margin: 0;
padding: 0;
position: relative;
}
}
.site-hero-content {
min-width: 100%;
background: pink;
clip-path: polygon(0 0, 100% 20%, 100% 100%, 0 100%);
position: relative;
margin-top: -120px;
margin: 0;
padding: 0;
}
@media only screen and (max-width: 500px) {
.site-hero-content {
min-width: 100%;
background: pink;
clip-path: polygon(0 0, 100% 10%, 100% 100%, 0 100%);
position: relative;
margin-top: -40px;
margin: 0;
padding: 0;
}
}
.new {
background: blue;
}
<div class="site-hero-colour"></div>
<div class="site-hero-content"></div>
<div class="new"> <h1>This gets cut off. It should sit on top of the white space or be positoned to match up.</h1></div>
In this new setup, the content moves down once the height limitation has been removed for that element. I am seeking opinions on better approaches than using top
or having an empty DIV here. Any feedback or alternative strategies would be greatly appreciated. Thank you.