so i have a container div which holds 5 other divs (see picture ) and on hover those divs slide in the direction the arrow is pointed ( to right of picture ). I achieved this simply with CSS's :hover property. However, it achieved it's purpose but I simply just do not like the result ( see snippet ); certain mouse positions would cause the div to go back to the original position then back to hovered position again. Any ideas for improving the hover property? Picture
body, html {
padding: 0;
margin: 0;
}
.body-container {
position: fixed;
overflow : hidden;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-size: cover;
overflow: hidden;
}
.ele-containers {
width: 50%;
overflow: hidden;
height: 50%;
position: absolute;
transition: 0.6s;
background: blue;
border: 2px white solid;
}
#spring {
top: 0;
left: 0;
}
#summer {
top: 0;
left: 50%;
}
#winter {
top: 50%;
left: 0;
}
#autumn {
top: 50%;
left: 50%;
}
#spring:before, #summer:before, #winter:before, #autumn:before {
content: '';
position: absolute;
width: 200px;
height: 200px;
background: white;
border-radius: 50%;
}
#spring:hover {
left: -10%;
top:-10%;
}
#winter:hover{
left:-15%;
top:65%;
}
#autumn:hover{
left:65%;
top:65%;
}
#summer:hover {
left: 65%;
top:-15%;
}
#spring:before {
bottom: -100px;
right: -100px;
}
#summer:before {
bottom: -100px;
left: -100px;
}
#winter:before {
top: -100px;
right: -100px;
}
#autumn:before {
top: -100px;
left: -100px;
}
#about-circle {
position: absolute;
border-radius: 100%;
transform: translate(-50%, -50%);
display: flex;
left: 50%;
top: 50%;
width: 200px;
height: 200px;
background: linear-gradient(rgb(244, 217, 193), rgb(204, 230, 255));
border: solid 4px rgba(255, 255, 255, .5);
}
<div class="body-container">
<div class="ele-containers" id="spring">Spring</div>
<div class="ele-containers" id="summer">Summer</div>
<div class="ele-containers" id="winter">Winter</div>
<div class="ele-containers" id="autumn">Autumn</div>
<div class="circle-container" id="about-circle"></div>
</div>
Instead of moving the main div, you create pseudo elements and move them.
When done like that, it will solve the hover issue.
Note, you might need to adjust the movement a little, I just made them up to show how-to
body,
html {
padding: 0;
margin: 0;
}
.body-container {
position: fixed;
overflow: hidden;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-size: cover;
overflow: hidden;
}
.ele-containers {
width: 50%;
overflow: hidden;
height: 50%;
position: absolute;
}
#spring {
top: 0;
left: 0;
}
#summer {
top: 0;
left: 50%;
}
#winter {
top: 50%;
left: 0;
}
#autumn {
top: 50%;
left: 50%;
}
#spring:before,
#summer:before,
#winter:before,
#autumn:before {
content: '';
position: absolute;
width: 200px;
height: 200px;
background: white;
transition: 0.6s;
border-radius: 50%;
transform-origin: left top;
}
#spring:before {
left: calc(100% - 100px);
top: calc(100% - 100px);
}
#summer:before {
top: calc(100% - 100px);
left: -100px;
}
#winter:before {
top: -100px;
left: calc(100% - 100px);
}
#autumn:before {
top: -100px;
left: -100px;
}
#spring:after,
#summer:after,
#winter:after,
#autumn:after {
content: '';
left: 0;
top: 0;
width: 100%;
height: 100%;
position: absolute;
transition: 0.6s;
background: blue;
border: 2px white solid;
transform-origin: left top;
z-index: -1;
}
#about-circle {
position: absolute;
border-radius: 100%;
transform: translate(-50%, -50%);
display: flex;
left: 50%;
top: 50%;
width: 200px;
height: 200px;
background: linear-gradient(rgb(244, 217, 193), rgb(204, 230, 255));
border: solid 4px rgba(255, 255, 255, .5);
}
#spring:hover::before,
#spring:hover::after {
transform: translate(-30%,-15%);
}
#winter:hover::before,
#winter:hover::after {
transform: translate(-15%,30%);
}
#autumn:hover::before,
#autumn:hover::after {
transform: translate(30%,15%);
}
#summer:hover::before,
#summer:hover::after {
transform: translate(30%,-15%);
}
<div class="body-container">
<div class="ele-containers" id="spring">Spring</div>
<div class="ele-containers" id="summer">Summer</div>
<div class="ele-containers" id="winter">Winter</div>
<div class="ele-containers" id="autumn">Autumn</div>
<div class="circle-container" id="about-circle"></div>
</div>
Related
First of all, I want to let you know that this task should be built using HTML & CSS only.
Secondly, I have to put [from 'sun' div to 'neck'div] as a sibilings to the checkbox in order to control it by css, and now the problem that How to show my checkbox out of it's parent div which is the 'outerCircle'.
body {
width: 50%;
height: 100%;
margin: 20px;
}
article {
position: absolute;
background-color: transparent;
width: 400px;
height: 60%;
margin-top: 40px;
margin-left: 20px;
}
.day {
background-color: #F2D16D;
position: relative;
border-radius: 50%;
left: 70px;
width: 12%;
height: 10%;
top: -15px;
box-shadow: 1px 1px 3px 3px#F2D16D;
}
.moon {
position: relative;
top: -60px;
left: 90%;
height: 40px;
width: 50px;
box-shadow: -12px 2px 0 8px #E1E1E1;
border-radius: 50%;
filter: drop-shadow(9px 9px 6px #E1E1E1);
}
.outerCircle {
/* top: -50%; */
position: absolute;
/* z-index: 1; */
width: 100%;
height: 80%;
border-radius: 50%;
border: 15px solid #46A679;
overflow: hidden;
display: block;
}
.innerCircle {
position: absolute;
z-index: -2;
background-color: #E0E0E0;
width: 210%;
height: 795%;
border-radius: 50%;
top: 205%;
left: -65%;
/* overflow: hidden; */
}
.sun {
background-color: #F2D16D;
position: relative;
width: 30%;
height: 120%;
border-radius: 50%;
left: 70%;
top: 280%;
}
.catBody {
position: relative;
z-index: -1;
background-color: #E4774F;
height: 460%;
width: 120%;
top: 180px;
right: 40px;
transform: translate(0%, 10%);
}
.leftear,
.rightear {
position: relative;
width: 0%;
height: 0%;
}
.leftear {
border-top: 70px solid transparent;
border-right: 100px solid #E4774F;
left: 100px;
bottom: 194%;
}
.rightear {
border-top: 70px solid transparent;
border-left: 100px solid #E4774F;
left: -40px;
bottom: 334%;
}
.leftEye {
position: relative;
z-index: 1;
background-color: white;
width: 15%;
height: 60%;
border-radius: 50%;
bottom: 220%;
left: 10%;
}
.rightEye {
position: relative;
z-index: 1;
background-color: white;
width: 15%;
height: 60%;
border-radius: 50%;
bottom: 280%;
left: 55%;
}
.noise {
position: fixed;
background-color: #0D0D0D;
/* z-index: 1; */
width: 3%;
height: 2%;
border-radius: 50%;
top: 410px;
left: 245px;
}
.neck {
position: absolute;
/* z-index: -1; */
width: 0;
height: 0;
top: 390;
left: -40px;
border-left: 120px solid transparent;
border-right: 120px solid transparent;
border-top: 120px solid white;
}
/* switch section */
.button input {
/* Remember: this is to clean the shape of the radio button */
opacity: 0;
width: 0;
height: 0;
}
.button:hover {
cursor: pointer;
}
.button {
display: inline-block;
position: absolute;
z-index: 3;
width: 200px;
height: 50px;
left: 120px;
top: -115;
}
.slider {
position: absolute;
top: -10;
left: 0;
right: 0;
bottom: 0;
background-color: #47AB84;
border-radius: 190px;
transition: .7s;
}
/* internal circle */
.slider:before {
position: absolute;
content: "";
left: 4px;
bottom: 4px;
background-color: #FBE26C;
transition: all .7s;
}
.round:before {
top: 5px;
width: 20px;
height: 20px;
border-radius: 50%;
border: 15px solid #65E3B5;
}
/* Animate the switch */
input:checked+.slider::before {
transform: translateX(140px);
}
#select1:checked~.innerCircle {
background-color: #0D0D0D;
}
#select1:checked~.sun {
background-color: white;
left: 0%;
}
#select1:checked~.leftEye {
height: 10%;
position: relative;
z-index: 1;
background-color: white;
width: 15%;
/* height: 60%; */
border-radius: 50%;
bottom: 220%;
/* left: 10%; */
}
#select1:checked~.rightEye {
height: 10%;
position: relative;
z-index: 1;
background-color: white;
width: 15%;
/* height: 60%; */
border-radius: 50%;
bottom: 230%;
/* left: 55%; */
}
.catBody:hover {
position: relative;
z-index: -1;
background-color: #E4774F;
height: 460%;
width: 120%;
top: 200px;
/* right: 30px; */
transform: translate(0%, 10%);
}
.catBody:hover~.leftear {
border-top: 70px solid transparent;
border-right: 100px solid #E4774F;
/* left: 110px; */
bottom: 150%;
}
.catBody:hover~.rightear {
border-top: 70px solid transparent;
border-left: 100px solid #E4774F;
/* left: -30px; */
bottom: 280%;
}
.catBody:hover~.rightEye {
height: 10%;
position: relative;
z-index: 1;
background-color: white;
width: 15%;
/* height: 60%; */
border-radius: 50%;
bottom: 230%;
/* left: 60%; */
}
.catBody:hover~.leftEye {
height: 10%;
position: relative;
z-index: 1;
background-color: white;
width: 15%;
/* height: 60%; */
border-radius: 50%;
bottom: 220%;
/* left: 15%; */
}
#select1:checked~.catBody:hover~.rightEye {
width: 15%;
height: 60%;
bottom: 280%;
/* left: 55%; */
}
#select1:checked~.catBody:hover~.leftEye {
width: 15%;
height: 60%;
/* left: 10%; */
}
<article role="img">
<div class="day"></div>
<div class="moon"></div>
<div class="whole">
<div class="outerCircle">
<label class="button" for="select1">
<input id="select1" type="checkbox">
<span class="slider round"></span>
<div class="innerCircle"></div>
<div class="sun"></div>
<div class="catBody"></div>
<div class="leftear"></div>
<div class="rightear"></div>
<div class="leftEye"></div>
<div class="rightEye"></div>
<div class="noise"></div>
<div class="neck"></div>
</label>
</div>
</div>
</article>
I had to put the divs and the checkbox inside it
because the outer circle should above all and the over flow of the 'catBody' should be behind the 'outerCircle' as shown in the picture,
and I tried to use z-index but it didn't work with me, because it effected on hover work. How do I deal with it?
I'm not an expert with html so this is why I'm asking this question, so I could create an hexagon, but I need to create another one inside of the hexagon created, so this is why I'm asking if any of you guys could help me, thanks in advance!
.octagonWrap {
width: 400px;
height: 400px;
float: left;
position: absolute;
overflow: hidden;
top: 30%;
left: 20%;
}
.octagon {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
transform: rotate(45deg);
background: rgb(255, 255, 255);
border: 3px solid rgb(0, 0, 0);
}
.octagon:before {
position: absolute;
/* There needs to be a negative value here to cancel
* out the width of the border. It's currently -3px,
* but if the border were 5px, then it'd be -5px.
*/
top: -3px;
right: -3px;
bottom: -3px;
left: -3px;
transform: rotate(45deg);
content: '';
border: inherit;
}
<div class='octagonWrap'>
<div class='octagon'></div>
<div class="octagontwo"></div>
</div>
Not sure how big you want the hexagon to be but this should give you a good starting point.
HTML
<div class='octagonWrap'>
<div class='octagon'></div>
</div>
<div class='octagonWrapTwo'>
<div class='octagontwo'></div>
</div>
CSS
.octagonWrap {
width: 400px;
height: 400px;
float: left;
position: absolute;
overflow: hidden;
top: 30%;
left: 20%;
}
.octagonWrapTwo {
width: 300px;
height: 300px;
float: left;
position: absolute;
overflow: hidden;
top: 45%;
left: 24%;
}
.octagon {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
transform: rotate(45deg);
background: rgb(255, 255, 255);
border: 3px solid rgb(0, 0, 0);
}
.octagontwo {
position: absolute;
top: 5px;
right: 5px;
bottom: 5px;
left: 5px;
overflow: hidden;
transform: rotate(45deg);
background: rgb(255, 255, 255);
border: 3px solid rgb(0, 0, 0);
}
.octagon:before {
position: absolute;
/* There needs to be a negative value here to cancel
* out the width of the border. It's currently -3px,
* but if the border were 5px, then it'd be -5px.
*/
top: -3px;
right: -3px;
bottom: -3px;
left: -3px;
transform: rotate(45deg);
content: '';
border: inherit;
}
.octagontwo:before {
position: absolute;
/* There needs to be a negative value here to cancel
* out the width of the border. It's currently -3px,
* but if the border were 5px, then it'd be -5px.
*/
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
transform: rotate(45deg);
content: '';
border: inherit;
}
I am trying to change the color of intersection in Venn Diagram.
Here's a pen demonstrating what I've done so far:
https://codepen.io/amolmt/pen/VJxNxM
.circle {
position: absolute;
width: 55%;
height: 55%;
border-radius: 50%;
p.circle__header {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
width: 100%;
max-width: 170px;
text-align: center;
font-size: 22px;
color: white;
}
}
I expect the output of intersection color to be white.
Venn diagram by using only css and html
**Html code**
<div id="outer1" class="outer">
</div>
<div id="outer2" class="outer">
</div>
<div id="midw1">
<div id="mid1" class="mid"></div>
</div>
<div id="midw2">
</div>
</div>
</div>
**css code**
div {
width: 240px;
height: 240px;
position: absolute;
border-radius: 50%;
}
.innerw {
left: 0px;
top: 0px;
overflow: hidden;
}
.innerw2 {
left: 170px;
top: 0px;
overflow: hidden;
}
.inner {
left: -85px;
top: 130px;
background-color: palegreen;
z-index: 20;
}
.inner:hover {
background-color: green;
}
#midw1 {
left: 0px;
top: 0px;
overflow: hidden;
}
#mid1 {
left: 170px;
top: 0px;
}
#midw2 {
left: 0px;
top: 0px;
overflow: hidden;
}
#mid2 {
left: 85px;
top: 130px;
}
#midw3 {
left: 170px;
top: 0px;
overflow: hidden;
}
.mid {
background-color: white;
z-index: 15;
}
#outer1 {
left: 0px;
top: 0px;
background:orange
}
#outer2 {
left: 170px;
top: 0px;
background:red
}
#outer3 {
left: 85px;
top: 130px;
}
.outer {
background-color: orange;
z-index: 10;
}
How can I accomplish such a square with css? I don't know how to create such a border and how to center the text that perfectly.
I expect you to do something like this!
CSS:
.parent {
width: 150px;
height: 150px;
position: relative;
top: 40px;
left: 50px;
transform: rotate(45deg);
}
.parent:before {
content: "";
width: 106px;
height: 106px;
background: rgb(20, 20, 134);
position: absolute;
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
}
.orange {
width: 100%;
height: 20px;
background: orange;
position: absolute;
}
.orange::before,
.orange::after {
content: "";
position: absolute;
width: 20px;
height: 50px;
background: orange;
}
.orange::after {
right: 0;
height: 95px;
}
.orange:last-of-type {
bottom: 0;
transform: scale(-1);
}
.date {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(-45deg);
color: #FFF;
line-height: 0;
}
<div class="parent">
<div class="orange"></div>
<div class="date">
<h4>May</h4>
<p>2018</p>
</div>
<div class="orange"></div>
</div>
I'm using the following HTML / CSS to overlay a box on a website i'm working on. I want the box to center in the screen, not start based on the centering already going on. So basically the white box should be on the center of the page, not the text test
.loading {
position: fixed;
z-index: 999;
height: 2em;
width: 2em;
overflow: show;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* Transparent Overlay */
.loading:before {
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
}
.centrediv {
height: 200px;
width: 800px;
background-color: white;
border: 1px solid black;
}
<div class="loading"><div class="centrediv">Test</div></div>
Use transform: translate(-50%, -50%), top: 50% and left: 50% on .centreDiv to center it horizontally and vertically.
.loading {
position: fixed;
z-index: 999;
height: 2em;
width: 2em;
overflow: visible;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* Transparent Overlay */
.loading:before {
content: '';
display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
.centrediv {
position: absolute;
height: 100px;
width: 200px;
background-color: white;
border: 1px solid black;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
<div class="loading">
<div class="centrediv">Test</div>
</div>