Auto height of parent div where child divs have skewed edges - html

I was working on a little something for myself and I walked into a problem i simply cant solve. I am trying to achieve a small effect where there are 2 divs with skewed edges. However, their parent div gets a scrollbar because the skew falls outside.
HTML
<div class="c-r">
<div class=" c-c c-r-l-1">
</div>
<div class="c-c c-r-r-1">
</div>
</div>
CSS
.c-r{
display: block;
height: auto;
overflow: auto;
}
.c-c{
width: 50%;
height: 300px;
margin-top: 150px;
position: relative;
display: inline-block;
float: left;
background: #44bf86;
}
.c-r-l-1:before, .c-r-l-1:after {
content: '';
width: 100%;
height: inherit;
position: absolute;
background: inherit;
z-index: -1;
transition: ease all .5s;
-webkit-transform:skewY(5deg) ;
-moz-transform: skewY(5deg);
-ms-transform: skewY(5deg);
-o-transform:skewY(5deg) ;
transform:skewY(5deg) ;
}
.c-r-l-1:before {
top: 0;
z-index: 12;
transform-origin: right top;
}
.c-r-l-1:after {
bottom: 0;
z-index: 12;
transform-origin: left bottom;
}
.c-r-r-1:before, .c-r-r-1:after {
content: '';
width: 100%;
height: inherit;
position: absolute;
background: inherit;
z-index: -1;
transition: ease all .5s;
}
.c-r-r-1:before {
top: 0;
transform-origin: left top;
transform: skewY(-5deg);
}
.c-r-r-1:after {
bottom: 0;
transform-origin: right bottom;
transform: skewY(-5deg);
}
#media screen and (max-width: 720px){
.c-r{
display: block;
overflow: auto;
}
.c-c{
width: 100%;
}
}
I am not really sure what other info I can give you than this. I hope you all can help me out and thank you for taking your time.
~Greetings

I found the fix to my problem.
All i had to do was add:
padding-top: 5%;
padding-bottom: 5%;
The reason why it has to be 5 is because my skew is going 5 degrees!
To my outer div. everything works fine now. Thanks everyone for their time!

Related

Skewing both top and bottom of div

I am trying to skew both the top and bottom of a div to create a shape that I can then insert a background pattern to however, after a few hours of research I can't really come up with a solid solution. I'm nearly there in the sense that all I need to do is to skew the bottom but am looking for some help or guidance on doing so.
I would like the bottom to mirror the skew of the top. Any suggestions?
#test {
position: relative;
width: 100%;
height: 400px;
}
.bg {
width: 50%;
height: 800px;
-webkit-transition: all 300ms ease-in;
background: black;
border-radius: 80px 0px 0px 80px;
position: absolute;
right: 0;
top: 0;
-ms-transform: skewY(-9deg);
-webkit-transform: skewY(-9deg);
transform: skewY(-9deg);
}
<section id="test">
<div class="bg"></div>
</section>
Example of what I currently have
https://jsfiddle.net/3atsj1e5/
With some rotation and perspective you can do it:
.box {
margin-left: auto;
width: 200px;
height: 450px;
transform-origin: right;
transform: perspective(100px) rotateY(-10deg);
border-radius: 40px 0 0 40px;
overflow: hidden;
}
.box::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url(https://picsum.photos/id/1074/400/800) center/cover;
transform-origin:inherit;
transform: perspective(100px) rotateY(10deg);
}
body {
margin: 0;
background:#eee;
}
<div class="box"></div>

Limit hover area of CSS shapes to :after

I am trying to make a sort of Venn-Diagram that is going to be used for navigation later.
I have three intersecting ellipsoids created with CSS shapes. Each ellipsoid, as well as their two intersections, will be distinct links later on. Also, when you hover over them they should pop out as per transform: scale(1.3).
My issue is that I'm using ellipsoids which are partially transparent with :after to create the intersections, which creates a problem when hovering over them because the :hover condition gets triggered when hovering anywhere on the partially transparent ellipsoid and not just the :after part. This means that the nonintersecting areas are not hoverable because they are obstructed by the other invisible ellipsoid.
I think the example will make this clearer.
Here is the code:
CSS:
.venn-container{position: relative; left: 0;}
.cat_one{
width: 400px;
height: 200px;
background: red;
border-radius: 200px / 100px;
position: absolute;
float: left;
opacity: 0.5;
}
.cat_two{
width: 400px;
height: 200px;
background: green;
border-radius: 200px / 100px;
position: absolute;
float: left;
left: 240px;
opacity: 0.5;
}
.cat_three{
width: 400px;
height: 200px;
background: blue;
border-radius: 200px / 100px;
position: absolute;
float: left;
left: 480px;
opacity: 0.5;
}
.int1{
background: transparent;
width: 400px;
height: 200px;
border-radius: 200px / 100px;
position: relative;
opacity: 0.5;
overflow: hidden;
float: left;
}
.int1:after{
background: black;
position: absolute;
content: '';
border-radius: 200px / 100px;
width: 400px;
height: 200px;
left: 240px;
}
.int1:hover{
transform: scale(1.3);
left: -35px;
}
.int2{
background: transparent;
width: 400px;
height: 200px;
border-radius: 200px / 100px;
position: relative;
opacity: 0.5;
overflow: hidden;
float: left;
left: 80px;
}
.int2:after{
background: black;
position: absolute;
content: '';
border-radius: 200px / 100px;
width: 400px;
height: 200px;
left: -240px;
}
.int2:hover{
transform: scale(1.3);
left: 115px;
}
HTML:
<div class="venn-container">
<div class="cat_one"></div>
<div class="cat_two"></div>
<div class="cat_three"></div>
<div class="int1"></div>
<div class="int2"></div>
</div>
And here is a fiddle: https://jsfiddle.net/y3Lvmuqg/2/
I would like the :hover to only get triggered in the intersections, and later make cat_one and cat_two hoverable outside the intersections.
I don't know if there is a way I'm doing this is the best and I'm open to suggestions.
Thanks for getting back to me #ge0rg I spent about an hour fiddling with CSS and HTML and came up with this code using just divs with background colors, hover events and border radius's (along with a few z-index and positioning techniques).
Hope you enjoy your reworked venn diagram...
You may have to mess around with the size, and definetly will have to mess with the positioning (however they're all inside a div and so it makes it so that you can just position the div and the rest will happen magically) I added a background color to the div just to show that nothing was transparent, and I also added a always on top function for viewing a section, and I hope you enjoy!
.Venn {
background: linear-gradient(to bottom right, blue, lightblue);
}
.d1:hover, .d2:hover, .d3:hover {
color: #565656;
animation: top 2s steps(2, end) forwards;
-webkit-animation: top 2s steps(2, end) forwards;
box-shadow: 0px 0px 20px white;
}
.d1, .d2, .d3 {
overflow-wrap: break-word;
}
.d1 center, .d3 center {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
}
.d1 {
padding: 10px;
width: 100px;
height: inherit;
z-index: 1;
position: absolute;
border-radius: 100%;
top: 0px;
}
.d3 {
padding: 10px;
width: 100px;
height: inherit;
z-index: 2;
position: absolute;
border-radius: 100%;
top: 0px;
left: 81px;
}
.d1:hover, .d3:hover {
transform: scale(1.05);
}
.d2 {
border-radius: 100% 0;
height: 90px;
width: 87.5px;
transform: rotate(-45deg) scale(.7);
position: absolute;
top: 15px;
left: 55.35px;
z-index: 3;
border: 1px solid black;
}
.d2b {
transform: rotate(45deg);
padding: 0;
margin: 0;
}
.d2b center {
position: relative;
left: 20px;
}
.d2:hover {
transform: rotate(-45deg);
}
.Venn {
height: 100px;
}
-webkit #keyframes top {
99% {
z-index: previous;
background-image: none;
}
100% {
z-index: 7;
}
}
#keyframes top {
99% {
z-index: previous;
background-image: none;
}
100% {
z-index: 7;
}
}
<div class="Venn" style="position: relative; left: 50px; width: 300px; height: 100px;">
<div class="d1" style=" background-color: grey;">
<center> 1 </center>
</div>
<div class="d2" style=" background-color: #AAAAAA;">
<div class="d2b" style="max-width: inherit;">
<center> 2 </center>
</div>
</div>
<div class="d3" style=" background-color: lightgrey;">
<center> 3 </center>
</div>
</div>
For those of you who would prefer a JSfiddle/ CodePen here you go a Codepen.

How do I position a circlular div halfway over an angled div?

I am currently trying to build a portfolio website. Here is my landing page idea:
The part that I am struggling with regarding this design is positioning the down arrow so that it straddles the angled div regardless of screen width.
The closest that I have been able to come is by assigning the following values to the button...
position: absolute;
top: 290px;
left: 30%;
Here is my code:
*,
*:before,
*:after {
box-sizing: border-box;
padding: 0;
margin: 0;
}
section {
width: 100%;
min-height: 400px;
}
.bg-hero {
background: #00C1F7;
position: relative;
}
.bg-dark {
background: #003342;
position: relative;
}
.angled-div::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: -1;
bottom: 0;
transform-origin: left bottom;
transform: skewY(-3deg);
z-index: 1;
}
.button {
height: 150px;
width: 150px;
position: absolute;
top: 290px;
left: 30%;
background: #003342;
border-radius: 150px;
z-index: 2;
}
.button span {
width: 100%;
text-align: center;
color: white;
position: absolute;
top: 20px;
font-size: 62px;
}
.button:hover {
cursor: pointer;
background: #004472
}
<section class="bg-hero"></section>
<div class="button"><span>↓</span></div>
<section class="bg-dark angled-div"></section>
Question
How do I position my div so that it is halfway over the angled div and remains exactly half way over the angled div no matter the screen width?
You can have a near perfect centering if you can change your markup:
Change the skewed pseudo element to a span and position the button inside the span so that the button is also skewed.
Center the button using the below and also make a reverse skew:
position: absolute;
top: 0;
left: 50%;
transform: translate(-50%, -100%) skew(3deg);
transform-origin: left bottom;
Now make the contents of the button vertical using transform: rotate(3deg) on the button span element.
Now you can change the value of top (say 50px) to push the button inside the skewed section as much as needed.
See demo below:
*,
*:before,
*:after {
box-sizing: border-box;
padding: 0;
margin: 0;
}
section {
width: 100%;
min-height: 400px;
}
.bg-hero {
background: #00C1F7;
position: relative;
}
.bg-dark {
background: #003342;
position: relative;
}
.angled-div > span{
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: -1;
bottom: 0;
transform-origin: left bottom;
transform: skewY(-3deg);
z-index: 1;
}
.button {
height: 150px;
width: 150px;
position: absolute;
top: 50px;
left: 50%;
transform: translate(-50%, -100%) skew(3deg);
background: #003342;
border-radius: 150px;
z-index: 2;
transform-origin: left bottom;
}
.button span {
width: 100%;
text-align: center;
color: white;
position: absolute;
top: 20px;
font-size: 62px;
transform: rotate(3deg);
}
.button:hover {
cursor: pointer;
background: #004472;
}
<section class="bg-hero"></section>
<section class="bg-dark angled-div">
<span>
<div class="button"><span>↓</span></div>
</span>
</section>

Css shape transition - bottom left

I'm new to css transform styles. So I failed to figure out this matter. I've played with this code. But it have the corner on right side. But I need that corner shape in left side. Like this way. How can I create that? or any other methods for this kind of situations?
div {
float: left;
height: 100px;
width: 200px;
margin: 50px;
color: beige;
transition: all 1s;
}
.skew {
padding: 10px;
position: relative;
background: tomato;
}
.skew:after {
position: absolute;
content: '';
background: inherit;
z-index: -1;
}
.skew.bottom:after {
width: 100%;
height: 80%;
}
.skew.bottom:after {
bottom: 0px;
left: 0px;
transform-origin: top left;
transform: skewY(22deg);
}
.skew.bottom {
margin-top: 10px;
}
<div class="skew bottom">Some content</div>
div {
float: left;
height: 100px;
width: 200px;
margin: 50px;
color: beige;
transition: all 1s;
}
.skew {
padding: 10px;
position: relative;
background: tomato;
}
.skew:after {
position: absolute;
content: '';
background: inherit;
z-index: -1;
}
.skew.bottom:after {
width: 100%;
height: 80%;
}
.skew.bottom:after {
top: 0px; /*CHANGED THIS*/
left: 0px;
transform-origin: top left;
transform: skewY(-22deg);/*CHANGED THIS*/
}
.skew.bottom {
margin-top: 100px; /*INCREASED THIS*/
}
<div class="skew bottom">Some content</div>
Explanation
From bottom: 0px to top: 0px : So that the after element starts at the top left corner of it's parent which is the .skew element itself.
From 22deg to -22deg: To rotate the after element counter clockwise. Since the transform-origin is set to top left it will rotate in a way that the left top corner of the after element aligns with the left top corner of the .skew element.
From margin-top: 0px to margin-top: 100px: Because transforms do not change other elements around it or make space when a transformation takes some part of the element out of the view, it's necessary to have enough margin so that we can view the element after skewing it.

CSS Flip effect fine tuning

So, I was trying to create flip effect with css and here I am... fiddle link: https://jsfiddle.net/Munja/db11mmut/
I have 2 sides, front and back side. Issue is, back side is hidden until front side is rotated for 180deg. I would like to avoid that and make back side partially visible during rotation of front side, in order to make fine flip effect.
Any suggestions? Thank you in advance!
Code:
.container {
position: relative;
width: 200px;
height: 200px;
}
.container:hover .el{
transform: rotateY(180deg);
}
.el {
position: relative;
display: block;
width: 100%;
height: 120%;
background: #eee;
transition: 0.6s;
transform-style: preserve-3d;
}
.front {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
float: left;
background: lightgreen;
backgace-visibility: hidden;
z-index: 2;
transform: rotateY(0deg);
}
.back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
float: left;
background: lightblue;
backgace-visibility: hidden;
transform: rotateY(180deg);
}
<div class="container">
<div class="el">
<div class="front">
Front Side
</div>
<div class="back">
Back Side
</div>
</div>
</div>
you have to remove transform: rotateY(0deg); and the z-index from the front class, here is a working example
https://jsfiddle.net/db11mmut/2/