How to create cube window with css?
border-image
with linear-gradient
can do it:
.box {
margin: 10px;
display: inline-block;
border-style:solid;
border-width:2px 2px 15px 15px;
border-image-slice:2 2 15 15; /* same as border-width*/
border-image-source:linear-gradient(-45deg,transparent 9px,red 0 calc(100% - 9px),transparent 0);
}
.content {
padding: 5px;
}
<div class="box">
<div class="content">
CONTENT<br> Some more Content
</div>
</div>
<div class="box">
<div class="content">
CONTENT<br> more Content
</div>
</div>
<div class="box">
<div class="content">
AA BB
</div>
</div>
Making a cube fill entire screen
Simply make the scene element 100vh
and consider 50vh
inside the translation. Also remove the width to have the default full width:
body { font-family: sans-serif;margin:0; } /* Remove the default margin */
* { box-sizing:border-box; /* to make sure there is no overflow*/}
.scene { height: 100vh;}
.cube { height: 100%; position: relative; transform-style: preserve-3d; transition: transform 1s;}
.cube:hover{ animation: pageDown 1.5s linear forwards;}
@keyframes pageDown{ 25%{ transform: scale(0.8); } 75%{ transform: rotateX(90deg); } 100%{ transform: scale(1); transform: rotateX(90deg); }}
.cube__face { position: absolute; width: 100%; height: 100%; border: 2px solid black; /* Optional Styling */ line-height: 200px; font-size: 30px; font-weight: bold; color: white; text-align: center;}
.cube__face--front { background: hsla( 0, 100%, 50%, 1);}
.cube__face--bottom { background: hsla(300, 100%, 50%, 1);}
.cube__face--front { transform: rotateY(0deg) translateZ(50vh);}
.cube__face--bottom { transform: rotateX(-90deg) translateZ(50vh); }
<div class="scene">
<div class="cube"> <div class="cube__face cube__face--front">entry page</div> <div class="cube__face cube__face--bottom">extra page</div> </div> </div>
Fullscreen CSS3 Cube Transition
Well, the calculus that you are asking is quite hard.
The good news is that you don't really need to do it.
Any object placed at 0 in the z direction won't be scaled by the perspective. So, the trick is to place the front face of the cube at z = 0px.
On the other side, to make this responsive, we will need to use viewport units. Like this :
html,body{ margin: 0; height: 100%; width: 100%;}
#experiment { perspective: 200vw; height: 100%; width: 100vw; border: solid 1px blue;}
.cube { position: relative; height: 100%; width: 100vw; transform-style: preserve-3d;}.face { position: absolute; height: 100%; width: 100%; color: #fff; transition: transform 4s linear;}.cube .front { transform: translateZ(-50vw) rotateY(0deg) translateZ(50vw); transform-origin: center center; background-color:gray;}
.cube .side { transform: translateZ(-50vw) rotateY(-90deg) translateZ(50vw); background-color:lightgray;}
.cube:hover .front { transform: translateZ(-50vw) rotateY(90deg) translateZ(50vw); }
.cube:hover .side { transform: translateZ(-50vw) rotateY(0deg) translateZ(50vw);}
<div id="experiment"> <div id="cube" class="cube" align="center"> <div id="front" class="face front"> front face </div> <div id="side" class="face side"> side face </div> </div></div>
Related Topics
Taghelpers Add Custom Class for Labeltaghelper Based on Validation Attribute [Required]
Using Attribute Value of a Parent in a Child Using CSS3 Attr Function
Zoom Out Shiny App at Default in Browser
Svg <Mask> Tag Required for Firefox But Appears to Break CSS Mask in Chrome
Gmail Responsive Email - Media Queries - Style Tag
Why Is the Two P-Tags Not Beside Each Other When the Screen Is Wide
Creating Rounded Corners in IE7/IE8
Set CSS3 Box-Shadow Not to Be on Top of Div
Center Vertically the Content of a Div
Bootstrap Grid Columns Not Stacking
What Is the Math Behind -Webkit-Perspective
Which Screen Reader Would Be Best to Test Site Accessibility and How to Configure That
A:Visited Links - Opacity Not Working
How to Change the Font Size of the List (Not the Initial View)
CSS Mystery: Width Being Set to 0Px Without Any CSS Rules
CSS Drop Down Navigation, 3Rd Level Issue
Should the Cursor Property Be Set in a Rule with or Without the :Hover Pseudo-Class