I want to 'cut' my page on two sides, something like this:
http://i.stack.imgur.com/ngZrp.jpg
DEMO: https://jsfiddle.net/r2g0eyxf/3/
#left {
background: url(https://static.pexels.com/photos/24353/pexels-photo.jpg);
width: 50%;
position: absolute;
left: 0px;
height: 100%;
}
#right {
background: url(http://media.caranddriver.com/images/media/51/25-cars-worth-waiting-for-lp-ferrari-488gtb-photo-658256-s-original.jpg);
width: 50%;
position: absolute;
right: 0px;
height: 100%;
}
But:
I need this images responsive
I want to create this 'slash'
How can I do this?
EDIT
This not solving my problem - I need it on full page and without space between images.
An hint would be to use transform and some padding.
average example
body {
margin: 0;
padding: 0;
width:100%;
overflow-x:hidden;
color:turquoise;
text-shadow:0 0 white;
font-size:2em;
}
#left {
position: absolute;
left: -10%;
height: 100%;
}
#left,
#right {
width: 60%;
transform: skew(-15deg);
overflow: hidden;
}
#left .content {
background: url(https://static.pexels.com/photos/24353/pexels-photo.jpg);
height: 100%;
}
#right .content {
height: 100%;
background: url(http://media.caranddriver.com/images/media/51/25-cars-worth-waiting-for-lp-ferrari-488gtb-photo-658256-s-original.jpg);
}
#right {
position: absolute;
right: -10%;
height: 100%;
}
#left .content,
#right .content{
width: 100%;
padding: 0 20%;
margin: 0 -15%;
transform: skew(15deg);
display: flex;
align-items: center;
justify-content: center;
background-size: cover;
}
<div id="left">
<div class="content">Content here</div>
</div>
<div id="right">
<div class="content">Content here</div>
</div>
You could use clip-path, support.
.clipped-img {
position: relative;
}
.clipped-img img {
position: absolute;
width: 50%;
}
.clipped-img img:nth-child(1) {
-webkit-clip-path: polygon( 0% 0, 100% 0, 80% 100%, 0 100% );
clip-path: polygon( 0% 0, 100% 0, 80% 100%, 0 100% );
}
.clipped-img img:nth-child(2) {
right: 10%;
-webkit-clip-path: polygon( 20% 0, 100% 0, 100% 100%, 0 100% );
clip-path: polygon( 20% 0, 100% 0, 100% 100%, 0 100% );
}
<div class="clipped-img">
<img src="http://placehold.it/500x300/FC0/">
<img src="http://placehold.it/500x300/CC0/">
</div>
Related
does anyone know how I can center the white circle into to middle of the blue circle and set the white circle above all other elements? I tried with relative and absolute positioning and with the z-index but I couldnt get it to work. I'm kinda a noob in CSS
.start-container {
height: 100vh;
display: grid;
grid-template-rows: 20% 65% 15%;
grid-template-areas: "header" "startpage" "footer";
}
.header {}
.header-shape {
height: 100%;
background-color: blue;
clip-path: polygon(0 60%, 100% 40%, 100% 100%, 0% 100%);
}
.profile-shape {
position: absolute;
top: 7vw;
left: 65vw;
width: 10vw;
height: 10vw;
background-color: blue;
border-radius: 50%;
filter: drop-shadow(0px 3px 30px rgba(0, 0, 0, 0.60));
}
.profile-picture {
width: 90%;
height: 90%;
background-color: white;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -50% 0 0 -50%;
}
.startpage {}
.footer {
background-color: yellow;
}
<div class="start-container">
<div class="header">
<div class="profile-shape">
<div class="profile-picture"></div>
</div>
<div class="header-shape"></div>
</div>
<div class="startpage"></div>
<div class="footer"></div>
</div>
If you give your shape a z-index, it will put it on top. Make it flex with justify-content and align-items center and that will centre your profile (after removing the absolute positioning):
.start-container {
height: 100vh;
display: grid;
grid-template-rows: 20% 65% 15%;
grid-template-areas: "header" "startpage" "footer";
}
.header {}
.header-shape {
height: 100%;
background-color: blue;
clip-path: polygon(0 60%, 100% 40%, 100% 100%, 0% 100%);
}
.profile-shape {
position: absolute;
top: 7vw;
left: 65vw;
width: 10vw;
height: 10vw;
background-color: blue;
border-radius: 50%;
filter: drop-shadow(0px 3px 30px rgba(0, 0, 0, 0.60));
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
}
.profile-picture {
width: 90%;
height: 90%;
background-color: white;
border-radius: 50%;
}
.startpage {}
.footer {
background-color: yellow;
}
<div class="start-container">
<div class="header">
<div class="profile-shape">
<div class="profile-picture"></div>
</div>
<div class="header-shape"></div>
</div>
<div class="startpage"></div>
<div class="footer"></div>
</div>
Per comment, if you want blue circle (changed to red in example below) below and white above, you would need to have an extra object otherwise the white circle will always be on the same stacking context as it's parent:
.start-container {
height: 100vh;
display: grid;
grid-template-rows: 20% 65% 15%;
grid-template-areas: "header" "startpage" "footer";
}
.header {}
.header-shape {
height: 100%;
background-color: blue;
clip-path: polygon(0 60%, 100% 40%, 100% 100%, 0% 100%);
}
.profile-placement {
position: absolute;
top: 7vw;
left: 65vw;
width: 10vw;
height: 10vw;
}
.profile-placement--shape {
background-color: red;
border-radius: 50%;
filter: drop-shadow(0px 3px 30px rgba(0, 0, 0, 0.60));
}
.profile-placement--picture {
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
}
.profile-picture {
width: 90%;
height: 90%;
background-color: white;
border-radius: 50%;
}
.startpage {}
.footer {
background-color: yellow;
}
<div class="start-container">
<div class="header">
<div class="profile-placement profile-placement--shape">
</div>
<div class="profile-placement profile-placement--picture">
<div class="profile-picture"></div>
</div>
<div class="header-shape"></div>
</div>
<div class="startpage"></div>
<div class="footer"></div>
</div>
Just adjust the margin with the remaining height and width on the profile-picture class.
The remaining size is 10% height and 10% weight. So there will be +5%(-45%) on the left margin and +5%(-45%) on the top margin. It will make the circle center
.start-container{
height: 100vh;
display: grid;
grid-template-rows: 20% 65% 15%;
grid-template-areas:
"header"
"startpage"
"footer"
;
}
.header{
}
.header-shape{
height: 100%;
background-color: blue;
clip-path: polygon(0 60%, 100% 40%, 100% 100%, 0% 100%);
}
.profile-shape{
position: absolute;
top: 7vw;
left: 65vw;
width: 10vw;
height: 10vw;
background-color: blue;
border-radius: 50%;
filter: drop-shadow(0px 3px 30px rgba(0,0,0,0.60));
}
.profile-picture{
width: 90%;
height: 90%;
background-color: white;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -45% 0 0 -45%;
}
.startpage{
}
.footer{
background-color: yellow;
}
<div class="start-container">
<div class="header">
<div class="profile-shape">
<div class="profile-picture"></div>
</div>
<div class="header-shape"></div>
</div>
<div class="startpage"></div>
<div class="footer"></div>
</div>
I have an image on a triangle background, however there is seen a line crossing the image. I tried using z-index together with position both relative and absolute, but it doesn't seem to work. Can someone help me out? Much appreciated.
/* Reset. */
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
/* Panels. */
.splitview {
position: relative;
width: 100%;
min-height: 45vw;
overflow: hidden;
}
.panel {
position: absolute;
width: 100vw;
min-height: 45vw;
overflow: hidden;
}
.panel .content {
position: absolute;
width: 100vw;
min-height: 45vw;
color: #FFF;
}
.panel .description {
width: 25%;
position: absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
.panel img {
box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);
width: 35%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.bottom {
background-color: rgb(44, 44, 44);
z-index: 1;
}
.bottom .description {
right: 5%;
}
.top {
background-color: rgb(77, 69, 173);
z-index: 2;
width: 50vw;
/*-webkit-clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);
clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);*/
}
.top .description {
left: 5%;
}
/* Handle. */
.handle {
height: 100%;
position: absolute;
display: block;
width: 5px;
top: 0;
left: 50%;
z-index: 3;
}
/* Skewed. */
.skewed .handle {
top: 50%;
transform: rotate(30deg) translateY(-50%);
height: 200%;
-webkit-transform-origin: top;
-moz-transform-origin: top;
transform-origin: top;
}
.skewed .top {
transform: skew(-30deg);
margin-left: -1000px;
width: calc(50vw + 1000px);
}
.skewed .top .content {
transform: skew(30deg);
margin-left: 1000px;
}
/* Responsive. */
#media (max-width: 900px) {
body {
font-size: 75%;
}
}
<div class="splitview skewed">
<div class="panel bottom">
<div class="content">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Original">
</div>
</div>
<div class="panel top">
<div class="content">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Duotone">
</div>
</div>
<div class="handle"></div>
</div>
Use only one image and put it outside the panels.
/* Reset. */
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
.splitview img {
z-index: 3;
box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);
width: 35%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* Panels. */
.splitview {
position: relative;
width: 100%;
min-height: 45vw;
overflow: hidden;
}
.panel {
position: absolute;
width: 100vw;
min-height: 45vw;
overflow: hidden;
}
.panel .content {
position: absolute;
width: 100vw;
min-height: 45vw;
color: #FFF;
}
.panel .description {
width: 25%;
position: absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
.bottom {
background-color: rgb(44, 44, 44);
z-index: 1;
}
.bottom .description {
right: 5%;
}
.top {
background-color: rgb(77, 69, 173);
z-index: 2;
width: 50vw;
/*-webkit-clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);
clip-path: polygon(60% 0, 100% 0, 100% 100%, 40% 100%);*/
}
.top .description {
left: 5%;
}
/* Handle. */
.handle {
height: 100%;
position: absolute;
display: block;
width: 5px;
top: 0;
left: 50%;
z-index: 3;
}
/* Skewed. */
.skewed .handle {
top: 50%;
transform: rotate(30deg) translateY(-50%);
height: 200%;
-webkit-transform-origin: top;
-moz-transform-origin: top;
transform-origin: top;
}
.skewed .top {
transform: skew(-30deg);
margin-left: -1000px;
width: calc(50vw + 1000px);
}
.skewed .top .content {
transform: skew(30deg);
margin-left: 1000px;
}
/* Responsive. */
#media (max-width: 900px) {
body {
font-size: 75%;
}
}
<div class="splitview skewed">
<div class="panel bottom">
<div class="content">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
</div>
</div>
<div class="panel top">
<div class="content">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
</div>
</div>
<div class="handle"></div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Duotone">
</div>
It can be hard to get two elements exactly lined up when there is some sort of transform or resizing going on because the arithmetic can result in part CSS pixel being required, and that can cause trouble translating to the multiple screen pixels that can make up a CSS pixel on modern, high res screens.
Your spurious line looks like not as wide as a CSS pixel and could be screen pixels 'left behind' during these calculations.
I found your layout quite hard to follow as there were skews and other transforms.
Looking at the layout I wonder if a simpler approach - a 3 column grid with flex used to center items within the panels might suffice? It would make maintenance easier. The skews seemed to be needed for the background 'triangular' shapes and this snippet replaces them with a sloping linear gradient as the content element's background. No skewing or other transforms are required.
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
font-size: 100%;
font-family: Arial, Helvetica, sans-serif;
}
.content {
position: absolute;
min-height: 45vw;
width: 100vw;
color: #fff;
text-align: center;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
background-image: linear-gradient(-60deg, rgb(44, 44, 44) 0, rgb(44, 44, 44) 48%, rgb(77, 69, 173) 48%, rgb(77, 69, 173) 100%);
}
.panel {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.panel .description {
width: 75%;
}
.panel img {
width: 100%;
height: 100%;
object-fit: contain;
/* commented out as I don't understand it's use here box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.15);*/
}
<body>
<div class="content">
<div class="panel">
<div class="description">
<h1>I dream about this girl everyday, but cannot seem to forget her.</h1>
<p>People say not many people can fall in love, and it's good I can experience it, but what is unrequited love worth actually.</p>
</div>
</div>
<div class="panel">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/original-image.jpg" alt="Original">
</div>
<div class="panel">
<div class="description">
<h1>My name is John Snow.</h1>
<p>I like making popcorn with icicles alot.</p>
</div>
</div>
</div>
<div class="handle"></div>
</div>
</body>
I'm trying to modify an existing css and make the semi-circle with the #E9EEF2 color thinner and shorter in width, but without any luck. So far everything I did was breaking the shape.
This is what I have so far as HTML:
.content {
display: flex;
}
.mask {
position: relative;
overflow: hidden;
display: block;
width: 12.5em;
height: 6.25em;
margin: 1.25em;
}
.semi-circle {
position: relative;
display: block;
width: 12.5em;
height: 6.25em;
background: #A148F7;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 8.75em;
height: 4.375em;
margin-left: -4.375em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle--mask {
position: absolute;
top: 0;
left: 0;
width: 12.5em;
height: 12.5em;
background: transparent;
transform: rotate(120deg) translate3d(0, 0, 0);
transform-origin: center center;
backface-visibility: hidden;
transition: all .3s ease-in-out;
}
.semi-circle--mask::before {
content: "";
position: absolute;
top: 0;
left: 0%;
z-index: 2;
display: block;
width: 12.625em;
height: 6.375em;
margin: -1px 0 0 -1px;
background: #DBDBDB;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.gauge--1 .semi-circle {
background: #A148F7;
}
<section class="content">
<div class="box gauge--1">
<div class="mask">
<div class="semi-circle"></div>
<div class="semi-circle--mask"></div>
</div>
</div>
</section>
You can find it in jsfiddle as well.
I know that I'm missing a small, but an important piece here, so please, give me a push, since I really have no idea how to modify the CSS
in order to keep the current shape.
To make the ring thinner, you need to increase the size of the inner semicircle that hides part of the outer semicircle making it look like a ring. I.e. modify the width, height, and negative left margin of .semi-circle::before.
To make the whole thing smaller, you need to decrease the width and height of all .mask, .semi-circle, .semi-circle--mask, and .semi-circle--mask::before. And then of course change the smaller semicircle too as mentioned above to fit the new size and your desired thickness of the ring.
Note that all heights should be half of the width of the same element. And the left margin of the .semi-circle::before should be negative half of the width of the same element.
Example with an 8em-wide gauge and a slightly thinner ring:
.content {
display: flex;
}
.mask {
position: relative;
overflow: hidden;
display: block;
width: 8em;
height: 4em;
margin: 1em;
}
.semi-circle {
position: relative;
display: block;
width: 8em;
height: 4em;
background: #A148F7;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 6em;
height: 3em;
margin-left: -3em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle--mask {
position: absolute;
top: 0;
left: 0;
width: 8em;
height: 8em;
background: transparent;
transform: rotate(120deg) translate3d(0, 0, 0);
transform-origin: center center;
backface-visibility: hidden;
transition: all .3s ease-in-out;
}
.semi-circle--mask::before {
content: "";
position: absolute;
top: 0;
left: 0%;
z-index: 2;
display: block;
width: 8em;
height: 4em;
margin: -1px 0 0 -1px;
background: #DBDBDB;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.gauge--1 .semi-circle {
background: #A148F7;
}
<section class="content">
<div class="box gauge--1">
<div class="mask">
<div class="semi-circle"></div>
<div class="semi-circle--mask"></div>
</div>
</div>
</section>
By modifying
.semi-circle::before {
...
width: 8.75em;
height: 4.375em;
margin-left: -4.375em;
...
}
This block sets up the bright half disk in the middle, so if you make that bigger, the outer "gauges" get thinner.
you can make the semicircle thinner if you increase the size of the inner semicircle:
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 10.75em;
height: 5.375em;
margin-left: -5.375em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
My problem is that I want to display 'arrows' above and below certain sections (which I have given classes of course).
These arrows can be both bottom, top and you can pick left and right for both the bottom and top arrow:
I made a snippet to demonstrate, but wasn't able to insert the SVG properly, so have replaced that code with background: red;.
The problem with above code is that it uses a wildcard selector on the classes, so it might interfere. So I would prefer something like class="arrow arrow-top arrow-left". However, that gives a problem when you add two arrows to one section: class="arrow arrow-top arrow-left arrow-bottom arrow-right".
Any suggestions on how to optimise this code?
[class*=arrow]:before, [class*=arrow]:after {
content: '';
display: none;
position: absolute;
left: 0;
right: 0;
height: 50px;
height: 12vw;
width: 100%;
//background-image: url("arrow.svg#svgView(preserveAspectRatio(none))");
background-color: red;
background-size: 100% 100%;
}
[class*=arrow-top] {
padding-top: 50px;
padding-top: 12vw;
}
[class*=arrow-bottom] {
padding-bottom: 50px;
padding-bottom: 12vw;
}
.arrow-top-left:before {
display: block;
top: 0;
}
.arrow-top-right:before {
display: block;
top: 0;
transform: scaleX(-1);
}
.arrow-bottom-left:after {
display: block;
bottom: 0;
transform: scaleY(-1);
}
.arrow-bottom-right:after {
display: block;
bottom: 0;
transform: scale(-1, -1);
}
/* unessential code */
section {
background-color: #EC644B;
height: 300px;
position: relative;
}
section:nth-child(odd) {
background-color: #DCC6E0;
}
p {
padding: 20px;
}
<section class="arrow arrow-top arrow-bottom-left">
<p>Een prachtige sectie</p>
</section>
<section class="arrow-top-right arrow-bottom-right">
<p>Een prachtige sectie</p>
</section>
<section class="arrow-bottom-right">
<p>Een prachtige sectie</p>
</section>
I would consider linear-gradient and you can easily achieve this by having two classes for each arrow that you can combine:
.top-arrow,.bottom-arrow {
margin:5px;
min-height:200px;
max-width:400px;
position:relative;
z-index:0;
border:1px solid;
}
.top-arrow:before,
.bottom-arrow:after{
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
.top-arrow:before {
background:
linear-gradient(to top right,transparent 50%,red 50.5%) top left/20% 50% no-repeat,
linear-gradient(to top left,transparent 50%,red 50.5%) top right/80% 50.5% no-repeat;
}
.bottom-arrow:after {
background:
linear-gradient(to bottom right,transparent 50%,pink 50.5%) bottom left /80% 50% no-repeat,
linear-gradient(to bottom left,transparent 50%,pink 50.5%) bottom right /20% 50.5% no-repeat;
}
<div class="top-arrow bottom-arrow">
</div>
<div class="bottom-arrow">
</div>
<div class="top-arrow">
</div>
Why not use CSS clip-path's to create the shapes you want within you :before's and :after's.
You will get a slick outcome, with solid corners and it will also be very easy to change their shape to your desires.
clip-path - CSS | MDN
CanIUse Support
clip-path Generator
body {
margin: 0;
padding: 0;
}
section {
padding: 30px;
height: 300px;
width: 100%;
background: #EC644B;
position: relative;
}
section:nth-child(odd) {
background: #DCC6E0
}
.arrow-top-left,
.arrow-top-right {
padding-top: 80px;
}
.arrow-top-left:before,
.arrow-top-right:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 80px;
background: blue;
}
.arrow-top-left:before {
-webkit-clip-path: polygon(20% 100%, 0 0, 100% 0);
clip-path: polygon(20% 100%, 0 0, 100% 0);
}
.arrow-top-right:before {
-webkit-clip-path: polygon(80% 100%, 0 0, 100% 0);
clip-path: polygon(80% 100%, 0 0, 100% 0);
}
.arrow-bottom-left,
.arrow-bottom-right {
padding-bottom: 80px;
}
.arrow-bottom-left:after,
.arrow-bottom-right:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 80px;
background: green;
}
.arrow-bottom-left:after {
-webkit-clip-path: polygon(20% 0, 0% 100%, 100% 100%);
clip-path: polygon(20% 0, 0% 100%, 100% 100%);
}
.arrow-bottom-right:after {
-webkit-clip-path: polygon(80% 0, 0% 100%, 100% 100%);
clip-path: polygon(80% 0, 0% 100%, 100% 100%);
}
<section class="arrow-top-left arrow-bottom-right">
</section>
<section class="arrow-bottom-right">
</section>
<section class="arrow-top-right">
</section>
A colleague thought about this and came up with this SASS-solution:
.u-arrow {
&-top,
&-bottom {
&-right,
&-left {
position: relative;
&:before,
&:after {
z-index: 0;
content: '';
display: none;
position: absolute;
left: 0;
right: 0;
height: 50px;
height: 12vw;
width: 100%;
background-size: 100% 100%;
background-image: url("/dist/images/arrow-white-mobile.svg");
.u-bg-blue & {
background-image: url("/dist/images/arrow-blue-mobile.svg");
}
#media (min-width: $screen-sm) {
background-image: url("/dist/images/arrow-white.svg");
.u-bg-blue & {
background-image: url("/dist/images/arrow-blue.svg");
}
}
#media (min-width: 1200px) {
height: 150px;
}
}
}
}
&-top {
&-left,
&-right {
padding-top: 50px;
padding-top: 12vw;
#media (min-width: 1200px) {
padding-top: 150px;
}
&:before {
display: block;
top: 0;
}
}
&-right {
&:before {
transform: scaleX(-1);
}
}
}
&-bottom {
&-left,
&-right {
padding-bottom: 50px;
padding-bottom: 12vw;
#media (min-width: 1200px) {
padding-bottom: 150px;
}
&:after {
display: block;
bottom: 0;
}
}
&-left {
&:after {
transform: scaleY(-1);
}
}
&-right {
&:after {
transform: scale(-1, -1);
}
}
}
}
I have a project:
Codepen
When I change browser size the letters climb to each other.
I need to find the way to lock the spaces between them. The letters has to be done like it is, I mean polygon. What to do to implant the letters to the divs, and has always the same spaces between them?
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.flexContainer {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
position: relative;
background: pink;
}
.letsPlay {
display: flex;
height: 50%;
width: 50%;
border: 2px solid red;
flex-wrap: wrap;
}
#lFirstLine {
position: relative;
background: lightgreen;
height: 50%;
width: 25%;
}
#eFirstLine {
position: relative;
background: green;
height: 50%;
width: 25%;
}
#tFirstLine {
position: relative;
background: lightgreen;
height: 50%;
width: 25%;
}
#sFirstLine {
position: relative;
background: green;
height: 50%;
width: 25%;
}
#pSecondLine {
position: relative;
background: CornflowerBlue;
width: 20%;
height: 50%;
}
#lSecondLine {
position: relative;
background: blue;
width: 20%;
height: 50%;
}
#aSecondLine {
position: relative;
background: CornflowerBlue;
width: 20%;
height: 50%;
}
#ySecondLine {
position: relative;
background: blue;
width: 20%;
height: 50%;
}
#exclamationMarkSecondLine {
position: relative;
background: CornflowerBlue;
width: 20%;
height: 50%;
}
.lFirst {
position: absolute;
background: black;
}
.lFirst.square {
right: 42px;
bottom: 7px;
height: 24px;
width: 24px;
transform: rotate(-45deg);
}
.lFirst.parallelogram {
right: 17px;
bottom: 1px;
height: 24px;
width: 24px;
transform: skew(-45deg);
}
.lFirst.triangleSmall1 {
right: 55px;
bottom: 1px;
height: 16.92px;
width: 33.84px;
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.lFirst.triangleSmall2 {
right: -7px;
bottom: -2px;
height: 16.92px;
width: 33.84px;
transform: rotate(135deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.lFirst.triangleMiddle {
right: 57px;
bottom: 86px;
height: 24px;
width: 48px;
transform: rotate(-45deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.lFirst.triangleBig1 {
right: 39px;
bottom: 19px;
height: 33.84px;
width: 67.68px;
transform: rotate(90deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.lFirst.triangleBig2 {
right: 38px;
bottom: 54px;
height: 33.84px;
width: 67.68px;
transform: rotate(-90deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.e {
position: absolute;
background: black;
}
.e.square {
right: 51px;
bottom: 36px;
height: 24px;
width: 24px;
transform: rotate(-90deg);
}
.e.parallelogram {
right: 32px;
bottom: 75px;
height: 24px;
width: 24px;
transform: skew(-45deg);
}
.e.triangleSmall1 {
right: 69px;
bottom: 41px;
height: 16.92px;
width: 33.84px;
transform: rotate(270deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.e.triangleSmall2 {
right: 8px;
bottom: -3px;
height: 16.92px;
width: 33.84px;
transform: rotate(135deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.e.triangleMiddle {
right: 20px;
bottom: 0px;
height: 24px;
width: 48px;
transform: rotate(-180deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.e.triangleBig1 {
right: 49px;
bottom: -5px;
height: 33.84px;
width: 67.68px;
transform: rotate(225deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
.e.triangleBig2 {
right: 49px;
bottom: 70px;
height: 33.84px;
width: 67.68px;
transform: rotate(-45deg);
clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
}
</style>
</head>
<body>
<div class="flexContainer">
<div class=letsPlay>
<div id=lFirstLine>
<div class="lFirst square"></div>
<div class="lFirst parallelogram"></div>
<div class="lFirst triangleSmall1"></div>
<div class="lFirst triangleSmall2"></div>
<div class="lFirst triangleMiddle"></div>
<div class="lFirst triangleBig1"></div>
<div class="lFirst triangleBig2"></div>
</div>
<div id=eFirstLine>
<div class="e square"></div>
<div class="e parallelogram"></div>
<div class="e triangleSmall1"></div>
<div class="e triangleSmall2"></div>
<div class="e triangleMiddle"></div>
<div class="e triangleBig1"></div>
<div class="e triangleBig2"></div>
</div>
<div id=tFirstLine></div>
<div id=sFirstLine></div>
<div id=pSecondLine></div>
<div id=lSecondLine></div>
<div id=aSecondLine></div>
<div id=ySecondLine></div>
<div id=exclamationMarkSecondLine></div>
</div>
</div>
Because the width on .letsPlay is a percentage, the boxes containing the letters will continue to shrink with the browser, and the letters will eventually push together.
To fix this, try a width of 500px or something similar on your .letsPlay element. Unfortunately, you'll need another solution if you want all your letters to fit in on devices thinner than 500px.
you can hard code a width in, instead of with a %. Change it from width-right: 500% to width-right: 500px - or whatever you want it to be