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.
Related
I found this code on https://thecodeplayer.com/index.php/walkthrough/3d-thumbnail-image-hover-effect and I want to make the image both responsive and whenever I change an image, the image has to scale to the div.
I tried to set: width: 100%; and height: auto; but it did not work. Is it because the HTML does not contain <img> tags? As I'm trying to learn I would appreciate any advice you have for me on how to solve this.
/*custom font - Montserrat*/
#import url(http://fonts.googleapis.com/css?family=Montserrat);
/*basic reset*/
* {margin: 0; padding: 0;}
/*forcing the body to take 100% height*/
html, body {min-height: 100%;}
/*a nice BG*/
body {
background: #544; /*fallback*/
background: linear-gradient(#544, #565);
}
/*Thumbnail Background*/
.thumb {
width: 400px; height: 300px; margin: 70px auto;
perspective: 1000px;
}
.thumb a {
display: block; width: 100%; height: 100%;
/*double layered BG for lighting effect*/
background:
linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
url("http://thecodeplayer.com/u/m/i1.png");
/*disabling the translucent black bg on the main image*/
background-size: 0, cover;
/*3d space for children*/
transform-style: preserve-3d;
transition: all 0.5s;
}
.thumb:hover a {transform: rotateX(80deg); transform-origin: bottom;}
/*bottom surface */
.thumb a:after {
/*36px high element positioned at the bottom of the image*/
content: ''; position: absolute; left: 0; bottom: 0;
width: 100%; height: 36px;
/*inherit the main BG*/
background: inherit; background-size: cover, cover;
/*draw the BG bottom up*/
background-position: bottom;
/*rotate the surface 90deg on the bottom axis*/
transform: rotateX(90deg); transform-origin: bottom;
}
/*label style*/
.thumb a span {
color: white; text-transform: uppercase;
position: absolute; top: 100%; left: 0; width: 100%;
font: bold 12px/36px Montserrat; text-align: center;
/*the rotation is a bit less than the bottom surface to avoid flickering*/
transform: rotateX(-89.99deg); transform-origin: top;
z-index: 1;
}
/*shadow*/
.thumb a:before {
content: ''; position: absolute; top: 0; left: 0;
width: 100%; height: 100%;
background: rgba(0, 0, 0, 0.5);
box-shadow: 0 0 100px 50px rgba(0, 0, 0, 0.5);
transition: all 0.5s;
/*by default the shadow will be almost flat, very transparent, scaled down with a large blur*/
opacity: 0.15;
transform: rotateX(95deg) translateZ(-80px) scale(0.75);
transform-origin: bottom;
}
.thumb:hover a:before {
opacity: 1;
/*blurred effect using box shadow as filter: blur is not supported in all browsers*/
box-shadow: 0 0 25px 25px rgba(0, 0, 0, 0.5);
/*pushing the shadow down and scaling it down to size*/
transform: rotateX(0) translateZ(-60px) scale(0.85);
}
<!-- Container -->
<div class="thumb">
<!-- Image -->
<a href="#">
<!-- Label -->
<span>Three-eyed Robot</span>
</a>
</div>
I'm trying to have an image inside a clip-path'd container display correctly. I wanted to add a slight zoom effect on hover as well.
A small part at the bottom is being cut off when not hovered.
However, once you hover the image and it zooms in, everything looks fine.
I cannot set a fixed height, which would solve the problem more easily since I want to add the image to a responsive flex container later.
I reduced the problem to its core in this jsfiddle: https://jsfiddle.net/pzf459cd/1/
.Image-Wrapper {
width: 50%;
}
.Image-Zoom-Wrapper {
clip-path: polygon(100% 0, 100% 91%, 62% 100%, 0 91%, 0 0, 62% 9%);
object-fit: contain;
}
.Image {
transition: all 0.5s linear;
}
.Image-Wrapper:hover .Image {
transform: scale(1.05, 1.05);
transition: all 0.5s linear;
}
body {
background-color: #000;
}
<div class="Image-Wrapper">
<div class="Image-Zoom-Wrapper">
<img class="Image" src="https://picsum.photos/id/304/500/300">
</div>
</div>
See my solution for a similiar task below. It works, but there might be an easier/better one.
jsfiddle: https://jsfiddle.net/fj5z7bue/
.wrap{
position: relative;
width: 50%;
filter: drop-shadow(3px 4px 8px rgba(38, 50, 56, 0.4));
}
.clip{
position: relative;
display: block;
overflow: hidden;
clip-path: polygon(60% 5%, 100% 0, 100% 95%, 60% 100%, 0 95%, 0 0);
height: 100%;
width: 100%;
background-color: rgb(240, 240, 240);
}
.pseudoimg{
width: 100%;
opacity: 0;
}
.img{
position: absolute;
top: 0;
left: 0;
z-index: 2;
background-image: url('https://picsum.photos/id/304/500/300');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
min-height: 100%;
min-width: 100%;
transform: scale(1);
transition: all 0.4s ease-out;
}
.wrap:hover{
cursor: pointer;
}
.wrap:hover .img{
transform: scale(1.4);
transition: all 12s ease-out;
}
.button{
position: absolute;
height: 60px;
width: 60px;
border-radius: 30px;
background-color: rgb(255, 255, 255);
z-index: 3;
right: -15px;
bottom: -5px;
filter: drop-shadow(3px 4px 8px rgba(38, 50, 56, 0.4));
}
<div class="wrap">
<div class="button"></div>
<div class="clip">
<img class="pseudoimg" src="https://picsum.photos/id/304/500/300"/>
<div class="img"></div>
</div>
</div>
I have little problem with my header. I want to create something like this:
I made this, but I couldn't get the third div to appear on the same line as the others. How can I do that?
I've tried Float: left and tried, display
.logo {
float:left;
height: 80px;
width:100%;
background-color: green;
-webkit-clip-path: polygon(0 0, 18% 0, 20% 100%, 0 100%);
clip-path: polygon(0 0, 18% 0, 23% 100%, 0 100%);
}
.photo1 {
background-color: red;
background-size: cover;
background-position: center center;
width: 100%;
height: 80px;
-webkit-clip-path: polygon(18% 0, 61% 0, 66% 100%, 23% 100%);
clip-path: polygon(18% 0, 61% 0, 66% 100%, 23% 100%);
}
.photo2 {
background-color:brown;
background-size: cover;
background-position: left center;
height: 80px;
-webkit-clip-path: polygon(62% 0, 100% 0, 100% 100%, 67% 100%);
clip-path: polygon(62% 0, 100% 0, 100% 100%, 67% 100%);
}
<div class="header">
<div class="logo"></div>
<div class="photo1"></div>
<div class="photo2"></div>
</div>
Set 3 DIVs:
position: absolute;
width: 100%;
Also adjust the polygon size of .photo2
.logo {
position: absolute;
height: 80px;
width:100%;
background-color: green;
-webkit-clip-path: polygon(0 0, 18% 0, 20% 100%, 0 100%);
clip-path: polygon(0 0, 18% 0, 23% 100%, 0 100%);
}
.photo1 {
position: absolute;
background-color: red;
background-size: cover;
background-position: center center;
width: 100%;
height: 80px;
-webkit-clip-path: polygon(18% 0, 61% 0, 66% 100%, 23% 100%);
clip-path: polygon(18% 0, 61% 0, 66% 100%, 23% 100%);
}
.photo2 {
position: absolute;
background-color:brown;
background-size: cover;
background-position: left center;
height: 80px;
width: 100%;
-webkit-clip-path: polygon(61% 0, 100% 0, 100% 100%, 66% 100%);
clip-path: polygon(61% 0, 100% 0, 100% 100%, 66% 100%);
}
<div class="header">
<div class="logo"></div>
<div class="photo1"></div>
<div class="photo2"></div>
</div>
How about something like this?
This also keeps the lines in a 45 degrees slope, no matter how wide the window is.
.header {
display: flex;
overflow: hidden;
}
.logo {
position: relative;
flex: 0 0 24%;
max-width: 24%;
height: 80px;
}
.logo:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: -100%;
right: 0;
bottom: 0;
background-color: green;
transform: skewX(45deg);
}
.photo1 {
position: relative;
flex: 0 0 38%;
max-width: 38%;
width: 100%;
height: 80px;
}
.photo1:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: -2px;
right: -2px;
bottom: 0;
background-color: red;
transform: skewX(45deg);
}
.photo2 {
position: relative;
flex: 0 0 38%;
max-width: 38%;
height: 80px;
}
.photo2:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: -100%;
bottom: 0;
background-color: brown;
transform: skewX(45deg);
}
<div class="header">
<div class="logo"></div>
<div class="photo1"></div>
<div class="photo2"></div>
</div>
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 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);
}
}