i want create Transversely div using css.
i want create look like show in following image.
following image
You can use:
transform: skew();
in your CSS.
Working Example:
body {
margin: 0;
}
.intro {
position: relative;
width: 65vw;
height: 100vh;
left: -15vw;
background-color: rgb(47, 47, 47);
transform: skew(-10deg);
}
<div class="intro">
</div>
something like this?
this is a quick copy/paste that i found on a site i made..
https://codepen.io/biroplane/pen/NpLrvE
#sx {
-webkit-clip-path: polygon(0 0, 95% 0, 74% 100%, 0% 100%);
clip-path: polygon(0 0, 100% 0, 84% 100%, 0% 100%);
background-image: url('https://unsplash.it/1920/1080/?random');
//background-image: url('http://loremflickr.com/1920/1080/dog,cat');
background-position: center center;
background-clip: border-box;
background-repeat: no-repeat;
background-size: cover !important;
background-attachment: scroll;
overflow: scroll;
width: 50vw !important;
height: 100vh;
display: flex;
align-items: center;
align-content: center;
flex-direction: column;
transition: all 0.5s cubic-bezier(.34, -0.32, .42, 1.34);
&:hover {
border: 10px solid white;
width: 100vw !important;
-webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
~ #dx {
//width:100vw !important;
}
h1 {
//margin-left: 25vw;
color: white;
#include textlongshadow(#222);
}
img {
//margin-left: 25vw;
#include longshadow();
//-webkit-filter:drop-shadow(10px 10px 10px white) drop-shadow(20px 20px 10px red);
//longdrop(20,#222);
}
}
Related
I have 2 clip-pathed div and they are so far from each other. How can I make it come closer?
My codepen : https://codepen.io/ugurcanTheReactDev/pen/BawLzdB?editors=1100
To make it more clear I have a photo like :
As you can see they are far from each other. I need to make them nearly together with so small a gap.
My codes :
HTML :
<div className="flex gap-1 h-72 mt-2">
<div className="exploreAreaDiv"> //First one.
<div className="exploreAreaDivOverlay">
<h1 className="text-4xl text-gray-100">EXPLORE THE AREA</h1>
</div>
</div>
<div className="covid-div " style={{ flex: 0.6 }}> //2nd one
<div className="covid-div-overlay">
<h1 className="text-4xl text-gray-100">EXPLORE THE AREA</h1>
</div>
</div>
</div>
CSS:
.exploreAreaDiv {
flex: 1;
cursor: pointer;
position: relative;
background: rgba(40, 40, 40, 1);
clip-path: polygon(0 0, 96% 0, 83% 100%, 0 100%);
background-position: center;
background-size: cover;
background-repeat: no-repeat;
overflow: hidden;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/d/d6/Love_Antalya.jpg");
}
.exploreAreaDivOverlay {
background-color: rgba(43, 42, 42, 0.5);
width: 100%;
height: 100%;
position: absolute;
clip-path: polygon(0 0, 96% 0, 83% 100%, 0 100%);
left: 0;
margin-left: -100vw;
font-size: 36px;
color: white;
transition: all 0.5s ease;
display: flex;
justify-content: center;
align-items: center;
}
.exploreAreaDiv:hover .exploreAreaDivOverlay {
margin-left: 0;
}
.covid-div {
width: 100%;
cursor: pointer;
position: relative;
background: rgba(40, 40, 40, 1);
clip-path: polygon(25% 0, 100% 0, 100% 100%, 3% 100%);
background-position: center;
background-size: cover;
overflow: hidden;
background-image: url("https://sedefed.org/wp-content/uploads/2020/03/coronavirus-4914026_1920.jpg");
}
Thank you.
I don't know much about clip-path but what actually happened is those two dives are in contact with each other and can't go over.
in the image, there is a dotted line that shows dives size.
what you have to do is make them overlap each other for some pixel or percentage.
if you don't want to make them overlap you can remove the image of one of the div and make it transparent then set the image to the parent div (flex gap-1 h-72 mt-2).
here I added transform: translateX(10%); in .exploreAreaDiv{} and transform: translateX(-10%); in .covid-div{}. i kept little space which looks good but you can remove it properly but setting transform: translateX(13%); and transform: translateX(-13%);.
.h-72{
height:200px;
}
.flex{
display:flex;
}
.gap-1{
}
.exploreAreaDiv {
flex: 1;
cursor: pointer;
position: relative;
background: rgba(40, 40, 40, 1);
clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%);
transform: translateX(10%);
background-position: center;
background-size: cover;
background-repeat: no-repeat;
overflow: hidden;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/d/d6/Love_Antalya.jpg");
}
.exploreAreaDivOverlay {
background-color: rgba(43, 42, 42, 0.5);
width: 100%;
height: 100%;
position: absolute;
clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%);
left: 0;
margin-left: -100vw;
font-size: 36px;
color: white;
transition: all 0.5s ease;
display: flex;
justify-content: center;
align-items: center;
}
.exploreAreaDiv:hover .exploreAreaDivOverlay {
margin-left: 0;
}
.covid-div {
width: 100%;
flex:0.6;
cursor: pointer;
position: relative;
background: rgba(40, 40, 40, 1);
transform: translateX(-10%);
clip-path: polygon(33% 0, 100% 0, 100% 100%, 0% 100%);
background-position: center;
background-size: cover;
overflow: hidden;
background-image: url("https://sedefed.org/wp-content/uploads/2020/03/coronavirus-4914026_1920.jpg");
}
.covid-div-overlay {
background-color: rgba(43, 42, 42, 0.5);
width: 100%;
height: 100%;
position: absolute;
clip-path: polygon(33% 0, 100% 0, 100% 100%, 0% 100%);
right: 0;
transition: all 0.5s ease;
margin-right: -100vw;
z-index: 5;
display: flex;
justify-content: center;
align-items: center;
}
.covid-div:hover .covid-div-overlay {
margin-right: 0;
}
<div class="flex gap-1 h-72 mt-2">
<div class="exploreAreaDiv">
<div class="exploreAreaDivOverlay">
<h1 class="text-4xl text-gray-100">EXPLORE THE AREA</h1>
</div>
</div>
<div class="covid-div ">
<div class="covid-div-overlay">
<h1 class="text-4xl text-gray-100">EXPLORE THE AREA</h1>
</div>
</div>
</div>
you can try other transform properties like transform: scaleX(1.2); or transform: skewX(10deg); but for using skew you have to make changes or have to remove the clip-path.
I have created a polygon triangle and I want to stack them next to each other
I have used shape-outside however it does not seem to be working.
I want this to be dynamic so more can be added without the need to change the code
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
}
div:nth-child(even) {
width: 280px;
height: 280px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
left: -137px;
}
div {
position: relative;
}
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
Simply adding margin-right: -274px; to div:nth-child(even) does the trick.
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
}
div:nth-child(even) {
width: 280px;
height: 280px;
margin-right: -274px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
left: -137px;
}
div {
position: relative;
}
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
You could use the pseudo selector of
:nth-child(even)
in order to select all 'even' elements.
I haven't used the clip-path (due to browser compatibility issues), so this wouldn't be the cleanest, but this (should) work on more browsers:
.parent {
height: 100px;
width: 100px;
margin: 2px;
display: inline-block;
position: relative;
overflow: hidden;
margin-left: -50px;
}
.parent:nth-child(odd) {
top: -50px;
}
.parent:first-child {
margin-left: 0;
}
.parent:nth-child(odd) .child {
position: absolute;
bottom: 0;
left: 0;
background: tomato;
height: 70%;
width: 70%;
transform: rotate(45deg);
transform-origin: bottom left;
}
.parent:nth-child(even) .child {
position: absolute;
top: 0;
left: 0;
background: tomato;
height: 70%;
width: 70%;
transform: rotate(-45deg);
transform-origin: top left;
}
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
I have fixed your css quickly (so pardon mistakes) , now they are aligning next to each other and you can add how many you want and they will alignt as long as there is space.
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
/* float: left; */
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
margin-left: -141px;
}
and
div:nth-child(even) {
width: 280px;
height: 280px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
/* float: left; */
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
/* left: -137px; */
margin-left: -141px;
}
and
body:nth-child(1){
margin-left:0; /* To clear the first marign */
}
I was wondering if it was possible to split a screen into 2 parts diagonally as shown on the picture. Once I'd hover over Picture A, the diagonal line would shift a bit to the right, revealing more of picture A while hiding a bit of picture B (I'm thinking transition?), and when I'd hover over picture B the opposite would happen.
Thanks in advance,
Martin
The diagonal image transition effect is unique request. I tried my best, Can you please check revealing effect.
section {
border: 1px solid black;
display: flex;
width: 400px;
box-sizing: border-box;
}
.diagonalHover {
position: absolute;
width: 66%;
height: 200px;
transition: all 0.3s ease-out;
}
.diagonalHover.first,
.diagonalHover.second {
background-image: url(https://cdn.pixabay.com/photo/2016/07/20/22/33/vajdahunyadvar-1531470_960_720.jpg);
background-repeat: no-repeat;
background-size: cover;
}
.diagonalHover.second {
background-image: url(https://cdn.pixabay.com/photo/2020/02/05/22/17/vendetta-4822543__340.jpg);
}
.diagonalHover.first:hover {
width: 75%;
z-index: 1;
}
.diagonalHover.second:hover {
width: 75%;
z-index: 1;
}
.diagonalHover.first:hover + .second {
}
.diagonalHover.first {
left: 0;
top: 0;
-webkit-clip-path: polygon(0 0, 100% 0%, 50% 100%, 0% 100%);
clip-path: polygon(0 0, 100% 0%, 50% 100%, 0% 100%);
}
.diagonalHover.second {
right: 0;
top: 0;
-webkit-clip-path: polygon(50% 0, 100% 0%, 100% 100%, 0% 100%);
clip-path: polygon(50% 0, 100% 0%, 100% 100%, 0% 100%);
}
<section>
<div class="diagonalHover first">
</div>
<div class="diagonalHover second">
</div>
</section>
I'm trying to create a border to my clip path using pseudo-elements. I have already tried to change positioning in them and my pseudoelement still stay on top of it. How can I change this?
You can see my code in here.
#shield {
z-index: 1;
background-color: red;
box-shadow: 1px 1px 1px black;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/9/91/Bras%C3%A3o_Porto_Feliz.png");
background-size: 50%;
background-repeat: no-repeat;
background-position: center;
background-blend-mode: multiply;
display: inline-block;
height: 120px;
width: 200px;
-webkit-clip-path: polygon(100% 0, 100% 75%, 50% 100%, 0% 75%, 0 0);
clip-path: polygon(100% 0, 100% 75%, 50% 100%, 0% 75%, 0 0);
}
#logo {
width: 100px;
height: 100px;
}
#shield::before {
top: 0;
left: 0;
transform: scale(1.2);
content:"";
display: block;
width: 100%;
height: 100%;
background-color: black;
position: absolute;
z-index: -1;
}
<div class="navbar-brand navbar-brand-centered" id="shield">
</div>
To see what I wanted to be in top of things, just delete the ::before element
Full example is in here
Thanks in advance :)
Just flip it around. Use your background image in your ::after and your black color for the actual div.
#shield {
z-index: 1;
background-color: black;
box-shadow: 1px 1px 1px black;
position: relative;
display: inline-block;
height: 120px;
width: 200px;
-webkit-clip-path: polygon(100% 0, 100% 75%, 50% 100%, 0% 75%, 0 0);
clip-path: polygon(100% 0, 100% 75%, 50% 100%, 0% 75%, 0 0);
}
#logo {
width: 100px;
height: 100px;
}
#shield::before {
top: 0;
left: 0;
transform: scale(1.2);
content:"";
display: block;
width: 100%;
height: 100%;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/9/91/Bras%C3%A3o_Porto_Feliz.png");
background-repeat: no-repeat;
background-position: center;
background-blend-mode: multiply;
position: absolute;
z-index: 1;
background-size: 50%;
}
<div id="shield"></div>
I have created a polygon triangle and I want to stack them next to each other
I have used shape-outside however it does not seem to be working.
I want this to be dynamic so more can be added without the need to change the code
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
}
div:nth-child(even) {
width: 280px;
height: 280px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
left: -137px;
}
div {
position: relative;
}
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
Simply adding margin-right: -274px; to div:nth-child(even) does the trick.
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
}
div:nth-child(even) {
width: 280px;
height: 280px;
margin-right: -274px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
float: left;
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
left: -137px;
}
div {
position: relative;
}
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
You could use the pseudo selector of
:nth-child(even)
in order to select all 'even' elements.
I haven't used the clip-path (due to browser compatibility issues), so this wouldn't be the cleanest, but this (should) work on more browsers:
.parent {
height: 100px;
width: 100px;
margin: 2px;
display: inline-block;
position: relative;
overflow: hidden;
margin-left: -50px;
}
.parent:nth-child(odd) {
top: -50px;
}
.parent:first-child {
margin-left: 0;
}
.parent:nth-child(odd) .child {
position: absolute;
bottom: 0;
left: 0;
background: tomato;
height: 70%;
width: 70%;
transform: rotate(45deg);
transform-origin: bottom left;
}
.parent:nth-child(even) .child {
position: absolute;
top: 0;
left: 0;
background: tomato;
height: 70%;
width: 70%;
transform: rotate(-45deg);
transform-origin: top left;
}
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
<div class="parent">
<div class="child"></div>
</div>
I have fixed your css quickly (so pardon mistakes) , now they are aligning next to each other and you can add how many you want and they will alignt as long as there is space.
div:nth-child(odd) {
width: 280px;
height: 280px;
background: #1e90ff;
-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
/* float: left; */
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
shape-outside: polygon(50% 0%, 0% 100%, 100% 100%);
margin-left: -141px;
}
and
div:nth-child(even) {
width: 280px;
height: 280px;
background: #1e90ff;
display: inline-block;
background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/Harry-Potter-1-.jpg) center center;
background-size: cover;
/* float: left; */
-webkit-clip-path: polygon(50% 100%, 0 0, 100% 0);
clip-path: polygon(50% 100%, 0 0, 100% 0);
shape-outside: polygon(50% 100%, 0 0, 100% 0);
/* left: -137px; */
margin-left: -141px;
}
and
body:nth-child(1){
margin-left:0; /* To clear the first marign */
}