i need to do an website with skewed css design. The goal is some similar design:
and my Result after some coding is the following:
in the black box you can see the problem: the ABC containers arent in the right positions. How i am able to fix that?
html, body {
margin: 0px;
padding: 0px;
width: 100%;
font-family: sans-serif;
font-size: 20px;
}
a {
text-transform: uppercase;
font-family: sans-serif;
font-size: 30px;
text-decoration: none;
margin-left: auto;
margin-right: auto;
font-weight: bold;
color: white;
}
.flex-container {
display: flex;
align-self: left;
flex-direction: row;
width: 70%;
height: 100%;
background-color: white;
overflow: hidden;
flex-wrap: wrap-reverse;
float: right;
}
.flex-content {
transform: skew(-5.5deg);
background-color: red;
height: 33%;
text-align: center;
width: 45%;
margin: 5px 5px 5px 50px;
display: flex;
align-items: center;
}
.underlay-box {
position: absolute;
width: 20%;
height: 100%;
background-color: red;
}
.overlay-box {
width: 30%;
height: 100%;
background-color: red;
transform: skew(-5.5deg);
float: left;
}
.gmk {
height: 100%;
width: 100%;
border: 2px red solid;
/*background: url('bild1.jpg'); */
background-size: cover;
}
<div class="underlay-box"></div>
<div class="overlay-box"></div>
<div class="flex-container">
<div class="flex-content">
<div class="gmk"><a href="mediothek.html">A</a></div>
</div>
<div class="flex-content"><a href="mediothek.html">B</a></div>
<div class="flex-content"><a href="mediothek.html">C</a></div>
<div class="flex-content"><a href="mediothek.html">D</a></div>
<div class="flex-content"><a href="mediothek.html">E</a></div>
<div class="flex-content"><a href="mediothek.html">F</a></div>
</div>
i would appreciate any help :) Thank you, Jonas
I believe the better approach would be to apply the skew
on the .flex-container
.
The basic problem is that you are skewing each element on its own so it is skewed in-place. Skewing the container will allow its contents to be skewed as well while following the the outer shape.
html, body {
margin: 0px;
padding: 0px;
width: 100%;
height:100%;
font-family: sans-serif;
font-size: 20px;
}
a {
text-transform: uppercase;
font-family: sans-serif;
font-size: 30px;
text-decoration: none;
margin-left: auto;
margin-right: auto;
font-weight: bold;
color: white;
}
.flex-container {
display: flex;
align-self: left;
flex-direction: row;
width: 70%;
height: 100%;
background-color: white;
overflow: hidden;
flex-wrap: wrap-reverse;
float: right;
transform: skew(-5.5deg);
}
.flex-content {
background-color: red;
height: 33%;
text-align: center;
width: 45%;
margin: 5px 5px 5px 15px;
display: flex;
align-items: center;
}
.underlay-box {
position: absolute;
width: 20%;
height: 100%;
background-color: red;
}
.overlay-box {
width: 30%;
height: 100%;
background-color: red;
transform: skew(-5.5deg);
float: left;
}
.gmk {
height: 100%;
width: 100%;
border: 2px red solid;
/*background: url('bild1.jpg'); */
background-size: cover;
box-sizing:border-box;
}
<div class="underlay-box"></div>
<div class="overlay-box"></div>
<div class="flex-container">
<div class="flex-content">
<div class="gmk"><a href="mediothek.html">A</a></div>
</div>
<div class="flex-content"><a href="mediothek.html">B</a></div>
<div class="flex-content"><a href="mediothek.html">C</a></div>
<div class="flex-content"><a href="mediothek.html">D</a></div>
<div class="flex-content"><a href="mediothek.html">E</a></div>
<div class="flex-content"><a href="mediothek.html">F</a></div>
</div>