I have a set of codes from the cube created using CSS.
However, how do I resize this into a bigger cube (for example, 200px)? I have tried but everytime I try doing it, it goes out of position..
.mainDiv {
position: relative;
width: 206px;
height: 190px;
margin: 0px auto;
margin-top: 100px;
}
.square {
width: 100px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: skew(180deg, 210deg);
position: absolute;
top: 43px;
}
.square2 {
width: 100px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: skew(180deg, 150deg);
position: absolute;
left: 102px;
top: 43px;
}
.square3 {
width: 114px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: rotate(150deg) translate(-40px, -16px) skew(30deg, 0deg);
position: absolute;
left: 0px;
top: -32px;
}
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
You may first adjust your code to make the shape easier by reducing the code and removing some fixed values then you only need to change the size of the main element to make the cube bigger or smaller:
* {
box-sizing:border-box;
}
.mainDiv {
position: relative;
width: 200px;
height: 100px;
margin: 120px auto 0;
font-size:0;
}
.mainDiv > * {
background: #c52329;
border: solid 2px #FFF;
}
.square,
.square2{
width: 50%;
height: 100%;
display:inline-block;
}
.square {
transform-origin:top left;
transform:skewY(30deg);
}
.square2 {
transform-origin:top right;
transform:skewY(-30deg);
}
.square3 {
width: calc(50% * 1.14);
height: 100%;
transform: rotate(-30deg) skewX(30deg);
position: absolute;
transform-origin:top left;
top:0;
}
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
<div class="mainDiv" style="width:100px;height:50px;">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
<div class="mainDiv" style="width:400px;height:200px;">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
You can also reduce the code using pseudo-element and introduce CSS variable to control the size:
.mainDiv {
position: relative;
--d:50px;
width: calc(var(--d) * 1.73 * var(--s, 1)); /* x sqrt(3) */
height: calc(var(--d) * var(--s, 1));
margin: calc(var(--d) * var(--s, 1)) auto;
}
.mainDiv:before,
.mainDiv:after {
content: "";
width: 50%;
height: 100%;
background:
linear-gradient(#c52329,#c52329) center/calc(100% - 4px) calc(100% - 4px) no-repeat,
#fff;
display: inline-block;
}
.mainDiv:before {
transform-origin: top left;
transform: skewY(30deg);
}
.mainDiv:after {
transform-origin: top right;
transform: skewY(-30deg);
}
.mainDiv>div {
position: absolute;
width: calc(50% * 1.154); /* x (1/cos(30)) */
padding-top:50%;
transform: rotate(-30deg) skewX(30deg);
background:
linear-gradient(#c52329,#c52329) center/calc(100% - 4px) calc(100% - 4px) no-repeat,
#fff;
top: 0;
transform-origin: top left;
}
<div class="mainDiv" style="--s:0.5"><div></div></div>
<div class="mainDiv"><div></div></div>
<div class="mainDiv" style="--s:1.5"><div></div></div>
<div class="mainDiv" style="--s:2"><div></div></div>
<div class="mainDiv" style="--s:3"><div></div></div>
You can even reduce more the code by relying on some gradient as background to create one part of the shape and remove the inner div and you will only have one element at the end:
.mainDiv {
position: relative;
--d:50px;
width: calc(var(--d) * 1.73 * var(--s,1));
height: calc(var(--d) * var(--s,1));
margin: 0 auto calc(var(--d) * var(--s,1));
background:
linear-gradient(to bottom left,#c52329 47%,transparent 48.5%) bottom left,
linear-gradient(to bottom right,#c52329 47%,transparent 48.5%) bottom right,
linear-gradient(to top left,#c52329 47%,transparent 48.5%) top left,
linear-gradient(to top right,#c52329 47%,transparent 48.5%) top right;
background-size:50.5% 50.5%;
background-repeat:no-repeat;
}
.mainDiv:before,
.mainDiv:after{
content:"";
width:50%;
height: 100%;
background:
linear-gradient(#c52329,#c52329) center/calc(100% - 4px) calc(100% - 4px) no-repeat,
#fff;
display:inline-block;;
}
.mainDiv:before {
transform-origin:top left;
transform:skewY(30deg) translateY(50%);
}
.mainDiv:after {
transform-origin:top right;
transform:skewY(-30deg) translateY(50%);
}
<div class="mainDiv"></div>
<div class="mainDiv" style="--s:1.5"></div>
<div class="mainDiv" style="--s:2"></div>
<div class="mainDiv" style="--s:3"></div>
The easier solution is to scale main container up. You can try to play with values to achieve desired size and position.
.mainDiv {
position: relative;
width: 206px;
height: 190px;
margin: 0px auto;
margin-top: 100px;
transform: scale(2) translate(5px, 70px);
}
.square {
width: 100px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: skew(180deg, 210deg);
position: absolute;
top: 43px;
}
.square2 {
width: 100px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: skew(180deg, 150deg);
position: absolute;
left: 102px;
top: 43px;
}
.square3 {
width: 114px;
height: 100px;
background: #c52329;
border: solid 2px #FFF;
transform: rotate(150deg) translate(-40px, -16px) skew(30deg, 0deg);
position: absolute;
left: 0px;
top: -32px;
}
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
Related
I know there are many different ways to draw in CSS but I want to draw this shape using CSS ::before and ::after pseudo-elements.
Only the yellow part I could not draw it.
.body{
width:100%;
height:100%;
background:#191919;
display: flex;
justify-content: center;
align-items: center;
}
.circle {
position: relative;
width: 160px;
height: 160px;
background: #824B20;
border-radius: 50%;
}
.circle::before{
content: "";
width: 100px;
height: 100px;
background: #E08027;
position: absolute;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.circle::after{
content:"";
/*color : #FFF58F */
}
<div class="body"><div class="circle";div><div><div>
An idea using only gradients:
.box {
width: 200px;
aspect-ratio:1;
border-radius: 50%;
background:
radial-gradient(circle at 78% 50%, yellow 4%,#0000 4.5%),
radial-gradient(circle at 22% 50%, yellow 4%,#0000 4.5%),
radial-gradient(at top,#0000 33%,yellow 34% 45%,#0000 46%)
bottom/100% 50% no-repeat,
radial-gradient(#E08027 40%,#824B20 41%);
}
<div class="box"></div>
.body {
width: 100%;
height: 100vh;
background: #191919;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.circle {
box-sizing: border-box;
position: relative;
width: 160px;
height: 160px;
background: #E08027;
border: 30px solid #824B20;
border-radius: 50%;
}
.half-circle {
position: absolute;
width: 85px;
height: 85px;
border: 14px solid #FFF58F;
border-top-color: transparent;
border-left-color: transparent;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(45deg);
}
.half-circle::before,
.half-circle::after {
content: "";
position: absolute;
top: 69px;
width: 14px;
height: 14px;
border-radius: 50%;
background: #FFF58F;
}
.half-circle::before {
left: 0;
}
.half-circle::after {
left: 71px;
transform: translate(-2px, -70px);
}
<div class="body">
<div class="circle">
<div class="half-circle"></div>
</div>
</div>
Can anyone please help with this? How to achieve the attached button with CSS only(no image)?
This is my code so far:
.triangle-up {
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 50px solid #555;
}
<div class="triangle-up"></div>
Use pseudo element where you apply a radial-gradient:
.box {
margin:60px 10px 0;
display:inline-block;
color:#fff;
text-align:center;
padding:10px 30px;
background:green;
border-radius:50px;
position:relative;
}
.box:before {
content:"";
position:absolute;
bottom:100%;
left:50%;
width:60px;
height:25px;
transform:translateX(-50%);
background:
radial-gradient(farthest-side at top left , transparent 98%,green 100%) left,
radial-gradient(farthest-side at top right, transparent 98%,green 100%) right;
background-size:50.2% 100%;
background-repeat:no-repeat;
}
body {
background:pink;
}
<div class="box">text here</div>
<div class="box">more and more text here</div>
<div class="box">2 lines <br>of text</div>
Another idea in case you want any kind of coloration:
.box {
margin:60px 10px 0;
display:inline-block;
color:#fff;
text-align:center;
padding:10px 30px;
background-image:linear-gradient(60deg,yellow,purple,green,blue);
background-size:100% calc(100% + 25px);
background-position:bottom;
border-radius:50px;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
bottom:0;
left:0;
right:0;
height:calc(100% + 25px);
background-image:inherit;
-webkit-mask:
radial-gradient(farthest-side at top left , transparent 98%,#fff 100%) left,
radial-gradient(farthest-side at top right, transparent 98%,#fff 100%) right;
mask:
radial-gradient(farthest-side at top left , transparent 98%,#fff 100%) left,
radial-gradient(farthest-side at top right, transparent 98%,#fff 100%) right;
-webkit-mask-size:30px 25px;
mask-size:30px 25px;
-webkit-mask-position:calc(50% - 15px) 0,calc(50% + 15px) 0;
mask-position:calc(50% - 15px) 0,calc(50% + 15px) 0;
-webkit-mask-repeat:no-repeat;
mask-repeat:no-repeat;
}
body {
background:pink;
}
<div class="box">text here</div>
<div class="box" style="
background-image:linear-gradient(160deg,white,red,black,orange);">more and more text here</div>
<div class="box" style="
background-image:linear-gradient(180deg,blue 20%,violet 20%,black);">2 lines <br>of text</div>
you can use the shadow on both rounded pseudos
.bubble {
position: relative;
background: #00aabb;
border-radius: 0.4em;
width: 200px;
height: 100px;
}
.bubble:after,
.bubble:before {
content: "";
position: absolute;
height: 3em;
width: 3em;
border-radius: 50%;
top: 100%;
margin: -1px;
}
:after {
left: 50%;
box-shadow: -0.8em -1.4em 0 -0.5em #00aabb
}
:before {
right: 50%;
box-shadow: 0.8em -1.4em 0 -0.5em #00aabb;
}
<div class='bubble'></div>
to understand how it works, give a background to the pseudo and another color to the shadows. You'll be able to reproduce for the sides or the top. It's a matter of the circle size and shadow's size and direction.
One option is to create a normal rectangle and then position two circles over it, such that they create a curved point.
In the demo below, this rectangle is represented by the .point div, and the circles are represented by the pseudo-elements ::before and ::after.
.caption {
position: relative;
width: 350px;
margin-top: 40px;
}
.caption>.content {
width: 100%;
height: 100%;
padding: 10px;
box-sizing: border-box;
border-radius: 30px;
background-color: green;
color: white;
text-align: center;
}
.caption>.point {
position: absolute;
left: 50%;
top: -30px;
width: 30%;
height: 30px;
transform: translateX(-50%) translateZ(1px);
overflow: hidden;
background-color: green;
}
.caption>.point::before,
.caption>.point::after {
content: '';
display: block;
width: 100%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border-radius: 100%;
background-color: white;
}
.caption>.point::before {
transform: translateX(-49%) translateY(-50%);
}
.caption>.point::after {
transform: translateX(49%) translateY(-50%);
}
<div class="caption">
<div class="point"></div>
<div class="content">This is some text!</div>
</div>
Here is a more visual demonstration of what the code is actually doing. The ::before and ::after elements are represented by the red circles. I've reduced the transparency of their fill to 50% so you can see which portion of the .point div they're cutting off.
.caption {
position: relative;
width: 350px;
margin-top: 40px;
}
.caption>.content {
width: 100%;
height: 100%;
padding: 10px;
box-sizing: border-box;
border-radius: 30px;
background-color: green;
color: white;
text-align: center;
}
.caption>.point {
position: absolute;
left: 50%;
top: -30px;
width: 30%;
height: 30px;
transform: translateX(-50%) translateZ(1px);
background-color: green;
}
.caption>.point::before,
.caption>.point::after {
content: '';
display: block;
width: 100%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border-radius: 100%;
background-color: rgba(255,255,255,0.5);
border: 1px solid red;
}
.caption>.point::before {
transform: translateX(-49%) translateY(-50%);
}
.caption>.point::after {
transform: translateX(49%) translateY(-50%);
}
<div class="caption">
<div class="point"></div>
<div class="content">This is some text!</div>
</div>
I'm having trouble with the code below.
I want the reflection of the windmill and all to be embedded inside the circle shape, but i'm unable to do so.
Please help me.
Thank you in advance.
Here is my html
body {
background-color: white;
}
#Circle {
background-color: #22304D;
background: linear-gradient(to bottom, #22304D, #5E7B9B);
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
overflow: hidden;
}
#Circle #cont {
background-color: transparent;
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
box-shadow: inset 0 0 100px black;
}
#Circle #cont .top {
height: 250px;
position: relative;
background-color: transparent;
border-top-left-radius: 900px;
border-top-right-radius: 900px;
}
.bottom {
display: inline-block;
position: relative;
margin-top: 390px;
opacity: 0.6;
filter: blur(2px);
transform: scaleY(-1);
}
.floor {
background-color: #1E2D49;
width: 468px;
margin-left: 16px;
position: absolute;
height: 20px;
margin-top: 320px;
z-index: 0;
}
.floor::after {
content: "";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
margin-top: -30px;
margin-left: -3px;
border-radius: 90% 100% 0 0;
}
.floor::before {
content: "";
background-color: content:"";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
border-radius: 90% 100% 0 0;
;
width: 347px;
height: 70px;
position: absolute;
transform: rotateX(45deg);
margin-left: 122px;
margin-top: -50px;
border-radius: 100% 100% 0 0;
}
.sky {}
.moon {
background-color: white;
width: 48px;
height: 48px;
z-index: 2;
border-radius: 100%;
position: absolute;
margin-left: 130px;
margin-top: 180px;
box-shadow: 0 0 5px white, 0 0 10px #1E2D49, 0 0 90px white;
}
.stars {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
display: block;
}
.stars {
background: url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
z-index: 0;
}
.mill {
background-color: #1E2D49;
width: 50px;
height: 140px;
transform: perspective(12px) rotateX(3deg);
position: absolute;
z-index: 3;
margin-top: 150px;
margin-left: 330px;
}
.mill::before {
content: "";
background-color: #FDC500;
width: 20px;
height: 20px;
position: absolute;
margin-left: 15px;
margin-top: 35px;
}
.mill::after {
content: "";
background-color: #FDC500;
width: 20px;
height: 25px;
position: absolute;
margin-left: 15px;
margin-top: 70px;
}
.dome {
background-color: #1E2D49;
width: 35px;
height: 35px;
position: absolute;
transform-origin: 0 100%;
transform: rotate(45deg);
overflow: hidden;
margin-left: 330px;
margin-top: 125px;
z-index: 4;
}
.fan {
background-color: #37475E;
/*37475E */
width: 10px;
height: 10px;
border-radius: 100%;
position: absolute;
margin-top: 155px;
margin-left: 350px;
z-index: 7;
animation-name: rotate_fan;
animation-duration: 6s;
animation-iteration-count: infinite;
}
.fan_blade1,
.fan_blade2,
.fan_blade3,
.fan_blade4 {
background-color: #37475E;
width: 4px;
height: 60px;
position: absolute;
z-index: 6;
margin-left: 35px;
margin-top: -28px;
border-left: 1.5px solid black;
border-top: 1px solid black;
transform: rotate(90deg);
}
.fan_blade2 {
transform: rotate(180deg);
margin-left: 1px;
margin-top: 5px;
}
.fan_blade3 {
transform: rotate(360deg);
margin-left: 3px;
margin-top: -60px;
}
.fan_blade4 {
transform: rotate(270deg);
margin-top: -28px;
margin-left: -30px;
}
.fan_blade1::before,
.fan_blade2::before,
.fan_blade3::before,
.fan_blade4::before {
content: "";
background-color: transparent;
width: 20px;
height: 45px;
margin-left: 5px;
background-size: 10px 11px;
background-image: linear-gradient(to left, gray 2px, transparent 1px), linear-gradient(to bottom, gray 2px, transparent 1px), linear-gradient(to top, gray 1px, transparent 0px);
position: absolute;
}
#keyframes rotate_fan {
from {}
to {
transform: rotate(360deg);
}
}
<div id="Circle">
<div id="cont">
<div class="top">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
<div class="bottom">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
</div>
</div>
You can clip the circle like this:
body {
background-color: white;
}
#Circle {
-webkit-clip-path: inset(0 0 0 0 round 250px);
clip-path: inset(0 0 0 0 round 250px);
background-color: #22304D;
background: linear-gradient(to bottom, #22304D, #5E7B9B);
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
overflow: hidden;
}
#Circle #cont {
background-color: transparent;
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
box-shadow: inset 0 0 100px black;
}
#Circle #cont .top {
height: 250px;
position: relative;
background-color: transparent;
border-top-left-radius: 900px;
border-top-right-radius: 900px;
}
.bottom {
display: inline-block;
position: relative;
margin-top: 390px;
opacity: 0.6;
filter: blur(2px);
transform: scaleY(-1);
}
.floor {
background-color: #1E2D49;
width: 468px;
margin-left: 16px;
position: absolute;
height: 20px;
margin-top: 320px;
z-index: 0;
}
.floor::after {
content: "";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
margin-top: -30px;
margin-left: -3px;
border-radius: 90% 100% 0 0;
}
.floor::before {
content: "";
background-color: content:"";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
border-radius: 90% 100% 0 0;
;
width: 347px;
height: 70px;
position: absolute;
transform: rotateX(45deg);
margin-left: 122px;
margin-top: -50px;
border-radius: 100% 100% 0 0;
}
.sky {}
.moon {
background-color: white;
width: 48px;
height: 48px;
z-index: 2;
border-radius: 100%;
position: absolute;
margin-left: 130px;
margin-top: 180px;
box-shadow: 0 0 5px white, 0 0 10px #1E2D49, 0 0 90px white;
}
.stars {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
display: block;
}
.stars {
background: url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
z-index: 0;
}
.mill {
background-color: #1E2D49;
width: 50px;
height: 140px;
transform: perspective(12px) rotateX(3deg);
position: absolute;
z-index: 3;
margin-top: 150px;
margin-left: 330px;
}
.mill::before {
content: "";
background-color: #FDC500;
width: 20px;
height: 20px;
position: absolute;
margin-left: 15px;
margin-top: 35px;
}
.mill::after {
content: "";
background-color: #FDC500;
width: 20px;
height: 25px;
position: absolute;
margin-left: 15px;
margin-top: 70px;
}
.dome {
background-color: #1E2D49;
width: 35px;
height: 35px;
position: absolute;
transform-origin: 0 100%;
transform: rotate(45deg);
overflow: hidden;
margin-left: 330px;
margin-top: 125px;
z-index: 4;
}
.fan {
background-color: #37475E;
/*37475E */
width: 10px;
height: 10px;
border-radius: 100%;
position: absolute;
margin-top: 155px;
margin-left: 350px;
z-index: 7;
animation-name: rotate_fan;
animation-duration: 6s;
animation-iteration-count: infinite;
}
.fan_blade1,
.fan_blade2,
.fan_blade3,
.fan_blade4 {
background-color: #37475E;
width: 4px;
height: 60px;
position: absolute;
z-index: 6;
margin-left: 35px;
margin-top: -28px;
border-left: 1.5px solid black;
border-top: 1px solid black;
transform: rotate(90deg);
}
.fan_blade2 {
transform: rotate(180deg);
margin-left: 1px;
margin-top: 5px;
}
.fan_blade3 {
transform: rotate(360deg);
margin-left: 3px;
margin-top: -60px;
}
.fan_blade4 {
transform: rotate(270deg);
margin-top: -28px;
margin-left: -30px;
}
.fan_blade1::before,
.fan_blade2::before,
.fan_blade3::before,
.fan_blade4::before {
content: "";
background-color: transparent;
width: 20px;
height: 45px;
margin-left: 5px;
background-size: 10px 11px;
background-image: linear-gradient(to left, gray 2px, transparent 1px), linear-gradient(to bottom, gray 2px, transparent 1px), linear-gradient(to top, gray 1px, transparent 0px);
position: absolute;
}
#keyframes rotate_fan {
from {}
to {
transform: rotate(360deg);
}
}
<div id="Circle">
<div id="cont">
<div class="top">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
<div class="bottom">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
</div>
</div>
Set position: relative; z-index: 1; to #Circle
body {
background-color: white;
}
#Circle {
position: relative;
z-index: 1;
background-color: #22304D;
background: linear-gradient(to bottom, #22304D, #5E7B9B);
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
overflow: hidden;
}
#Circle #cont {
background-color: transparent;
width: 500px;
height: 500px;
border-radius: 100%;
margin: 0 auto;
box-shadow: inset 0 0 100px black;
}
#Circle #cont .top {
height: 250px;
position: relative;
background-color: transparent;
border-top-left-radius: 900px;
border-top-right-radius: 900px;
}
.bottom {
display: inline-block;
position: relative;
margin-top: 390px;
opacity: 0.6;
filter: blur(2px);
transform: scaleY(-1);
}
.floor {
background-color: #1E2D49;
width: 468px;
margin-left: 16px;
position: absolute;
height: 20px;
margin-top: 320px;
z-index: 0;
}
.floor::after {
content: "";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
margin-top: -30px;
margin-left: -3px;
border-radius: 90% 100% 0 0;
}
.floor::before {
content: "";
background-color: content:"";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
border-radius: 90% 100% 0 0;
;
width: 347px;
height: 70px;
position: absolute;
transform: rotateX(45deg);
margin-left: 122px;
margin-top: -50px;
border-radius: 100% 100% 0 0;
}
.sky {}
.moon {
background-color: white;
width: 48px;
height: 48px;
z-index: 2;
border-radius: 100%;
position: absolute;
margin-left: 130px;
margin-top: 180px;
box-shadow: 0 0 5px white, 0 0 10px #1E2D49, 0 0 90px white;
}
.stars {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
display: block;
}
.stars {
background: url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
z-index: 0;
}
.mill {
background-color: #1E2D49;
width: 50px;
height: 140px;
transform: perspective(12px) rotateX(3deg);
position: absolute;
z-index: 3;
margin-top: 150px;
margin-left: 330px;
}
.mill::before {
content: "";
background-color: #FDC500;
width: 20px;
height: 20px;
position: absolute;
margin-left: 15px;
margin-top: 35px;
}
.mill::after {
content: "";
background-color: #FDC500;
width: 20px;
height: 25px;
position: absolute;
margin-left: 15px;
margin-top: 70px;
}
.dome {
background-color: #1E2D49;
width: 35px;
height: 35px;
position: absolute;
transform-origin: 0 100%;
transform: rotate(45deg);
overflow: hidden;
margin-left: 330px;
margin-top: 125px;
z-index: 4;
}
.fan {
background-color: #37475E;
/*37475E */
width: 10px;
height: 10px;
border-radius: 100%;
position: absolute;
margin-top: 155px;
margin-left: 350px;
z-index: 7;
animation-name: rotate_fan;
animation-duration: 6s;
animation-iteration-count: infinite;
}
.fan_blade1,
.fan_blade2,
.fan_blade3,
.fan_blade4 {
background-color: #37475E;
width: 4px;
height: 60px;
position: absolute;
z-index: 6;
margin-left: 35px;
margin-top: -28px;
border-left: 1.5px solid black;
border-top: 1px solid black;
transform: rotate(90deg);
}
.fan_blade2 {
transform: rotate(180deg);
margin-left: 1px;
margin-top: 5px;
}
.fan_blade3 {
transform: rotate(360deg);
margin-left: 3px;
margin-top: -60px;
}
.fan_blade4 {
transform: rotate(270deg);
margin-top: -28px;
margin-left: -30px;
}
.fan_blade1::before,
.fan_blade2::before,
.fan_blade3::before,
.fan_blade4::before {
content: "";
background-color: transparent;
width: 20px;
height: 45px;
margin-left: 5px;
background-size: 10px 11px;
background-image: linear-gradient(to left, gray 2px, transparent 1px), linear-gradient(to bottom, gray 2px, transparent 1px), linear-gradient(to top, gray 1px, transparent 0px);
position: absolute;
}
#keyframes rotate_fan {
from {}
to {
transform: rotate(360deg);
}
}
<div id="Circle">
<div id="cont">
<div class="top">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
<div class="bottom">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
</div>
</div>
Like in similar questions (Overflow hidden with border radius not working in chrome), it seems that setting
#Circle {
position: relative;
z-index: 1;
}
will solve your issue.
increase width and height of #circle and #Circle #cont so its display properly
body {
background-color: white;
}
#Circle {
background-color: #22304D;
background: linear-gradient(to bottom, #22304D, #5E7B9B);
width: 570px;
height: 570px;
border-radius: 100%;
margin: 0 auto;
overflow: hidden;
z-index:-2px;
position:absolute;
}
#Circle #cont {
background-color: transparent;
width: 570px;
height: 570px;
border-radius: 100%;
margin: 0 auto;
box-shadow: inset 0 0 100px black;
}
#Circle #cont .top {
height: 250px;
position: relative;
background-color: transparent;
border-top-left-radius: 900px;
border-top-right-radius: 900px;
}
.bottom {
display: inline-block;
position: relative;
margin-top: 390px;
opacity: 0.6;
filter: blur(2px);
transform: scaleY(-1);
}
.floor {
background-color: #1E2D49;
width: 468px;
margin-left: 16px;
position: absolute;
height: 20px;
margin-top: 320px;
z-index: 0;
}
.floor::after {
content: "";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
margin-top: -30px;
margin-left: -3px;
border-radius: 90% 100% 0 0;
}
.floor::before {
content: "";
background-color: content:"";
background-color: #1E2D49;
width: 200px;
height: 50px;
position: absolute;
transform: rotateX(45deg);
border-radius: 90% 100% 0 0;
;
width: 347px;
height: 70px;
position: absolute;
transform: rotateX(45deg);
margin-left: 122px;
margin-top: -50px;
border-radius: 100% 100% 0 0;
}
.sky {}
.moon {
background-color: white;
width: 48px;
height: 48px;
z-index: 2;
border-radius: 100%;
position: absolute;
margin-left: 130px;
margin-top: 180px;
box-shadow: 0 0 5px white, 0 0 10px #1E2D49, 0 0 90px white;
}
.stars {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
display: block;
}
.stars {
background: url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
z-index: 0;
}
.mill {
background-color: #1E2D49;
width: 50px;
height: 140px;
transform: perspective(12px) rotateX(3deg);
position: absolute;
z-index: 3;
margin-top: 150px;
margin-left: 330px;
}
.mill::before {
content: "";
background-color: #FDC500;
width: 20px;
height: 20px;
position: absolute;
margin-left: 15px;
margin-top: 35px;
}
.mill::after {
content: "";
background-color: #FDC500;
width: 20px;
height: 25px;
position: absolute;
margin-left: 15px;
margin-top: 70px;
}
.dome {
background-color: #1E2D49;
width: 35px;
height: 35px;
position: absolute;
transform-origin: 0 100%;
transform: rotate(45deg);
overflow: hidden;
margin-left: 330px;
margin-top: 125px;
z-index: 4;
}
.fan {
background-color: #37475E;
/*37475E */
width: 10px;
height: 10px;
border-radius: 100%;
position: absolute;
margin-top: 155px;
margin-left: 350px;
z-index: 7;
animation-name: rotate_fan;
animation-duration: 6s;
animation-iteration-count: infinite;
}
.fan_blade1,
.fan_blade2,
.fan_blade3,
.fan_blade4 {
background-color: #37475E;
width: 4px;
height: 60px;
position: absolute;
z-index: 6;
margin-left: 35px;
margin-top: -28px;
border-left: 1.5px solid black;
border-top: 1px solid black;
transform: rotate(90deg);
}
.fan_blade2 {
transform: rotate(180deg);
margin-left: 1px;
margin-top: 5px;
}
.fan_blade3 {
transform: rotate(360deg);
margin-left: 3px;
margin-top: -60px;
}
.fan_blade4 {
transform: rotate(270deg);
margin-top: -28px;
margin-left: -30px;
}
.fan_blade1::before,
.fan_blade2::before,
.fan_blade3::before,
.fan_blade4::before {
content: "";
background-color: transparent;
width: 20px;
height: 45px;
margin-left: 5px;
background-size: 10px 11px;
background-image: linear-gradient(to left, gray 2px, transparent 1px), linear-gradient(to bottom, gray 2px, transparent 1px), linear-gradient(to top, gray 1px, transparent 0px);
position: absolute;
}
#keyframes rotate_fan {
from {}
to {
transform: rotate(360deg);
}
}
<div id="Circle">
<div id="cont">
<div class="top">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
<div class="bottom">
<div class="dome"></div>
<div class="fan">
<div class="fan_blade1"></div>
<div class="fan_blade2"></div>
<div class="fan_blade3"></div>
<div class="fan_blade4"></div>
</div>
<div class="mill"></div>
<div class="sky">
<div class="stars"></div>
<div class="moon"></div>
</div>
<div class="floor">
</div>
</div>
</div>
</div>
I have this square: https://jsfiddle.net/34f93mL3/
As you can see, when you hover over it, the top folds down and when it reaches the bottom it becomes a polkadotted pink.
However, what I want to happen is for it to mimic an actual folding motion, meaning it should not have polkadots until it's "folded" a little more.
Here is the full code, which uses only HTML and CSS:
body {
background: white
}
#slow-container {
top: 100px;
left: 200px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
#slow-container:before {
top: -50px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
#slow-container2 {
top: -50px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
.slow-parent1 {
height: 0;
overflow: hidden;
background: lightgreen;
}
.slow-parent2 {
background: white;
}
.slow-parent3 {
height: 300px;
background: red;
}
#slow-container2 {
transition: all 1s linear;
transform-origin: bottom center;
}
#slow-container:hover #slow-container2 {
transform: rotateX(180deg);
background-color: lightpink;
background-image: radial-gradient(#fff 10%, transparent 10%), radial-gradient(#fff 10%, transparent 10%);
background-size: 30px 30px;
background-position: 0 0, 15px 15px;
}
<div id="slow-container">
<div id="slow-container2">
</div>
<div class="slow-parent1">
<div class="slow-parent2">
<div class="slow-parent3">
stuff goes here later
</div>
</div>
</div>
</div>
</div>
Just remove in your hover style code #fff 10%, from radial gradient
Use CSS3 properties perspective to feel folding effect.
References: https://css-tricks.com/almanac/properties/p/perspective/
body {
background: white
}
#slow-container {
top: 100px;
left: 200px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
#slow-container:before {
top: -50px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
#slow-container2 {
top: -50px;
height: 50px;
position: absolute;
width: 100px;
background: lightblue;
}
.slow-parent1 {
height: 0;
overflow: hidden;
background: lightgreen;
}
.slow-parent2 {
background: white;
}
.slow-parent3 {
height: 300px;
background: red;
}
#slow-container2 {
transition: all 1s linear;
transform-origin: bottom center;
}
#slow-container:hover #slow-container2 {
transform: perspective(200px) rotateX(180deg);
background-color: lightpink;
background-image: radial-gradient(#fff 10%, transparent 10%), radial-gradient(#fff 10%, transparent 10%);
background-size: 30px 30px;
background-position: 0 0, 15px 15px;
}
<div id="slow-container">
<div id="slow-container2">
</div>
<div class="slow-parent1">
<div class="slow-parent2">
<div class="slow-parent3">
stuff goes here later
</div>
</div>
</div>
</div>
I am trying to create a footer according to a design I received ...
The background color on the left is different from the right one:
I have the following markup:
<div class"wrapper">
<div class="content">
The Text here should no go over the logo
</div>
</div>
My idea is Content DIV to have the logo as background image aligned left and no repeat.
But then I don't know how to create the different color on left and right ...
And I am not sure if I can control the height so that everything aligns.
The content div is centered and has the orange border on the image ...
Thank You,
Miguel
Try this http://codepen.io/nicknameless/pen/cblzB/
I've used CSS3 and no additional markup. This should work for you. It could be cleaned up I think, this is just a quick overview to get you started.
The HTML you provided
<div class="wrapper">
<div class="content">
The Text here should no go over the logo
</div>
</div>
The CSS
html, body {
padding: 0;
margin: 0;
}
div.wrapper {
height: 40px;
background: #850000;
width: 100%;
display: block;
position: relative;
overflow: visible;
top: calc( 100px - 40px );
}
div.wrapper:before {
background: transparent url('http://placehold.it/100x100') no-repeat 0 0;
content: " ";
width: 100px;
height: 100px;
position: absolute;
bottom: 0;
left: 10%;
}
div.content {
left: calc( 10% + 100px );
padding-left: 10px;
bottom: 0;
background-color: #C70000;
display: block;
height: 40px;
position: absolute;
width: calc( 100% - ( 10% + 100px ) );
}
It's was really a pain in the ass, I recommend to take the inner rectangle as a picture, but if you really want it in CSS, here it's: http://jsfiddle.net/B97ym/
HTML:
<div class='wrapper'>
<div class="content">The Text</div>
<div class='border'>
<div class='border2'></div>
<div class='border3'></div>
<div class='logodiv'>
<div class='rectangle'></div>
</div>
</div>
CSS:
.wrapper {
width: 500px;
height: 50px;
margin: 100px auto;
position: relative;
background: linear-gradient(to right, #9c9e9f 40%, #000000 40%);
}
.content{
margin: 0 0 0 50%;
color: #ffffff;
}
.border{
width: 4em;
height: 4em;
background: #FF0000;
position: absolute;
left: 33.7%;
top: -55%;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
background: linear-gradient(to top, #000000 62%, #9c9e9f 62%);
}
.border2{
width: 0.8em;
height: 4em;
background: #9c9e9f;
position: absolute;
left: 80%;
}
.border3{
width: 0.8em;
height: 0.85em;
background: #000000;
position: absolute;
left: 80%;
top: 80%;
}
.logodiv {
width: 2.5em;
height: 2.5em;
background: #ffffff;
position: absolute;
top: 18%;
left: 18%;
}
.rectangle{
width: 2.1em;
height: 2.1em;
position: relative;
background: #ffffff;
top: -42%;
left: -42%;
-ms-transform: rotate(45deg); /* IE 9 */
-webkit-transform: rotate(45deg); /* Chrome, Safari, Opera */
transform: rotate(45deg);
}
Hope it's will be helpful to someone (:
Use a CSS background-image on the wrapper layer that contains the entire logo, bars an all. Add enough margin-left on the inner layer to shove the text beyond the logo.
Create a div with two div's inside with 50% width for left and right and fixed height. Make sure you overflow the logo.
I wonder if this FIDDLE will give you a place to start.
CSS
.holder {
width: 500px;
margin: 100px auto;
position: relative;
}
.leftdiv {
width: 40%;
height: 60px;
float: left;
background-color: red;
}
.rightdiv {
width: 60%;
height: 60px;
float: left;
background-color: blue;
}
.logodiv {
width: 44px;
height: 44px;
position: absolute;
left: 157px;
top: -42px;
background-color: white;
transform: rotate(45deg);
border-left: 20px solid blue;
border-right: 20px solid red;
border-top: 20px solid red;
border-bottom: 20px solid blue;
}
.whiteout {
background-color: white;
width: 30px;
height: 60px;
border: 0px solid black;
position: absolute;
top: -60px;
left: 183px;
}