I'm trying to modify an existing css and make the semi-circle with the #E9EEF2 color thinner and shorter in width, but without any luck. So far everything I did was breaking the shape.
This is what I have so far as HTML:
.content {
display: flex;
}
.mask {
position: relative;
overflow: hidden;
display: block;
width: 12.5em;
height: 6.25em;
margin: 1.25em;
}
.semi-circle {
position: relative;
display: block;
width: 12.5em;
height: 6.25em;
background: #A148F7;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 8.75em;
height: 4.375em;
margin-left: -4.375em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle--mask {
position: absolute;
top: 0;
left: 0;
width: 12.5em;
height: 12.5em;
background: transparent;
transform: rotate(120deg) translate3d(0, 0, 0);
transform-origin: center center;
backface-visibility: hidden;
transition: all .3s ease-in-out;
}
.semi-circle--mask::before {
content: "";
position: absolute;
top: 0;
left: 0%;
z-index: 2;
display: block;
width: 12.625em;
height: 6.375em;
margin: -1px 0 0 -1px;
background: #DBDBDB;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.gauge--1 .semi-circle {
background: #A148F7;
}
<section class="content">
<div class="box gauge--1">
<div class="mask">
<div class="semi-circle"></div>
<div class="semi-circle--mask"></div>
</div>
</div>
</section>
You can find it in jsfiddle as well.
I know that I'm missing a small, but an important piece here, so please, give me a push, since I really have no idea how to modify the CSS
in order to keep the current shape.
To make the ring thinner, you need to increase the size of the inner semicircle that hides part of the outer semicircle making it look like a ring. I.e. modify the width, height, and negative left margin of .semi-circle::before.
To make the whole thing smaller, you need to decrease the width and height of all .mask, .semi-circle, .semi-circle--mask, and .semi-circle--mask::before. And then of course change the smaller semicircle too as mentioned above to fit the new size and your desired thickness of the ring.
Note that all heights should be half of the width of the same element. And the left margin of the .semi-circle::before should be negative half of the width of the same element.
Example with an 8em-wide gauge and a slightly thinner ring:
.content {
display: flex;
}
.mask {
position: relative;
overflow: hidden;
display: block;
width: 8em;
height: 4em;
margin: 1em;
}
.semi-circle {
position: relative;
display: block;
width: 8em;
height: 4em;
background: #A148F7;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 6em;
height: 3em;
margin-left: -3em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.semi-circle--mask {
position: absolute;
top: 0;
left: 0;
width: 8em;
height: 8em;
background: transparent;
transform: rotate(120deg) translate3d(0, 0, 0);
transform-origin: center center;
backface-visibility: hidden;
transition: all .3s ease-in-out;
}
.semi-circle--mask::before {
content: "";
position: absolute;
top: 0;
left: 0%;
z-index: 2;
display: block;
width: 8em;
height: 4em;
margin: -1px 0 0 -1px;
background: #DBDBDB;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
.gauge--1 .semi-circle {
background: #A148F7;
}
<section class="content">
<div class="box gauge--1">
<div class="mask">
<div class="semi-circle"></div>
<div class="semi-circle--mask"></div>
</div>
</div>
</section>
By modifying
.semi-circle::before {
...
width: 8.75em;
height: 4.375em;
margin-left: -4.375em;
...
}
This block sets up the bright half disk in the middle, so if you make that bigger, the outer "gauges" get thinner.
you can make the semicircle thinner if you increase the size of the inner semicircle:
.semi-circle::before {
content: "";
position: absolute;
bottom: 0;
left: 50%;
z-index: 2;
display: block;
width: 10.75em;
height: 5.375em;
margin-left: -5.375em;
background: #E9EEF2;
border-radius: 50% 50% 50% 50%/100% 100% 0% 0%;
}
Related
I'm trying to create this icon using pure css & a single div
so far I've only managed to add 2 points like this:
:root {
--gear_radius: 5rem;
--gear_color: black;
--gear_thickness: 1.5rem;
--gear_pin_length: 1.5rem;
--gear_pin_gap: 1.5rem;
}
.gear {
margin: 5rem;
height: var(--gear_radius);
width: var(--gear_radius);
border-radius: 50%;
border: var(--gear_color) var(--gear_thickness) solid;
box-sizing: border-box;
position: relative;
}
.gear:before {
position: absolute;
content: "";
display: block;
height: var(--gear_pin_length);
width: var(--gear_thickness);
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(45deg);
box-shadow: 0 calc(var(--gear_thickness) * 2) 0 0 black, 0 calc(var(--gear_thickness) * -2) 0 0 black;
}
.gear:after {
position: absolute;
content: "";
display: block;
height: var(--gear_pin_length);
width: var(--gear_thickness);
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(-45deg);
box-shadow: 0 calc(var(--gear_thickness) * 2) 0 0 black, 0 calc(var(--gear_thickness) * -2) 0 0 black;
}
<div class="gear"></div>
How do I add 2 more points at the top and bottom? I don't know what approach to take from here?
The original picture of a gear wheel has an angle to the sides of each tooth.
However, I notice that in your part-solution you aren't worried about that and have parallel edges.
Here's a snippet that puts in all 6 teeth with parallel edges.
It uses before and after pseudo elements which had stripes as background and are rotated. The main div also has a stripe for a background but additionally a radial gradient with white and black circles.
.cog {
width: 30vmin;
height: 30vmin;
position: relative;
background-image: radial-gradient(white 0 35%, black 35% 70%, transparent 70% 100%), linear-gradient(to right, black, black);
background-size: 70% 70%, 25% 100%;
}
.cog::before,
.cog::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(to right, black, black);
background-size: 25% 100%;
z-index: -1;
}
.cog,
.cog::before,
.cog::after {
background-repeat: no-repeat;
background-position: center center;
transform-origin: center;
}
.cog::before {
transform: rotate(60deg);
}
.cog::after {
transform: rotate(120deg);
}
<div class="cog"></div>
Here's what it produces:
To get more sophisticated shape - such as the slope on the teeth, you could do more with gradients or just CSS clip-path (though by the time you've done this you probably might as well have created an SVG).
Well, of course SVG is better, but since your question is more of a challenge, here is my solution:
* {
margin: 0;
padding: 0;
}
.icon {
position: relative;
background: beige;
height: 160px;
width: 160px;
}
.wheel {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 32px;
height: 32px;
background: beige;
border-radius: 50%;
border: solid 24px brown;
}
.cog {
position: absolute;
width: 24px;
height: 120px;
border-radius: 6px;
background: brown;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.cog:nth-child(2) {
transform: rotate(45deg);
}
.cog:nth-child(3) {
transform: rotate(90deg)
}
.cog:nth-child(4) {
transform: rotate(135deg)
}
<div class="icon">
<div class="cogs">
<div class="cog"></div>
<div class="cog"></div>
<div class="cog"></div>
<div class="cog"></div>
</div>
<div class="wheel"></div>
<div>
As we know, in CSS, we can use:
width : 100px; height : 100px; border-radius : 100% 0 0 0;
To paint a sector with 90deg; and I want to use this way to paint a sector with any deg. But the front sector doesn't cover perfectly. It leaks a slice of red sector and I don't know how to handle it.
body {
background-color: #fbb;
}
.box {
width: 200px;
height: 200px;
position: relative;
background-color: #f00;
border-radius: 100% 0 0;
}
.box::after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: #fbb;
border-radius: 100% 0 0;
-webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
<div class="box"></div>
You can cheat a bit and shift the whole overlay with an additional transform.
body {
background-color: #fbb;
}
.box {
width: 200px;
height: 200px;
position: relative;
background-color: #f00;
border-radius: 100% 0 0;
}
.box::after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: #fbb;
border-radius: 100% 0 0;
transform-origin: 100% 100%;
transform: rotate(45deg) translate(-1px, 0px); /* <---- here */
}
<div class="box"></div>
It also seems to work by shifting the transform origin slightly.
body {
background-color: #fbb;
}
.box {
width: 200px;
height: 200px;
position: relative;
background-color: #f00;
border-radius: 100% 0 0;
}
.box::after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: #fbb;
border-radius: 100% 0 0;
transform-origin: 101% 100%; /* <---- here */
transform: rotate(45deg);
}
<div class="box"></div>
You could also use a sharp box shadow.
body {
background-color: #fbb;
}
.box {
width: 200px;
height: 200px;
position: relative;
background-color: #f00;
border-radius: 100% 0 0;
}
.box::after {
content: '';
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: #fbb;
border-radius: 100% 0 0;
transform-origin: 100% 100%;
transform: rotate(45deg);
box-shadow: 0 0 0 .5px #fbb; /* <---- here */
}
<div class="box"></div>
None of these are mathematically perfect, but they may suit your practical needs.
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>
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.
Hellow Guys,
I'm creating a loading animation with HTML and CSS. As I'm not really skilled in responsive front-end, I'm really struggling with making the text and the circle responsive.
What I really want is to attach the div with the background image and the text to the bar and make them responsive in order not to move and remain at the same position.
This is what I want to achieve:
Here's the code of what I have at the moment. I've tried attachment fixed and stuff like that, but the main problem is that the image keeps scaling when I use a max height/width and the text moves to the right depending on the width of the website.
Hope you can help me, thanks in advise.
body {
background: #111 url("");
background-size: 25vmin;
background-repeat: no-repeat;
background-position: center 40%;
height: 100vh;
margin: 0;
}
.logo {
background: url("https://openclipart.org/download/256338/whitecircle.svg");
background-size: 25vmin;
background-repeat: no-repeat;
position: absolute;
left: 28%;
bottom: 10vh;
height: 25vh;
width: 100px;
max-width: 150px;
}
h1 {
color: #fff;
position: absolute;
bottom: 20vh;
left: 35%;
}
.progress {
width: 400px;
max-width: 85vw;
height: 8px;
position: absolute;
bottom: 20vh;
left: 50%;
background: rgba(255, 255, 255, 0.5);
transform: translate(-50%, -50%);
overflow: hidden;
}
.progress:after {
content: '';
display: block;
width: 100%;
height: 8px;
background: #fff;
animation: load 5s linear;
}
#-moz-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-o-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<div class="logo"> </div>
<h1 class="title"> Loading </h1>
<div class="progress"> </div>
What I normally do to make an item responsive and many parts need to work closely together is, create a container which holds all items that are related. Then within the container I align item using % so they scale nicely. The main container (in my example called loader) I use width and height using the vh and vw units.
Here's one way you can solve this. I've also replaced the SVG with a circle made using css. This way you don't need to load the image. It will make your page less resource heavy. Let me know if you specifically want to use the SVG and I can update the example.
NOTE: I added a light border to the loader div so you can see how it resized when you resize the window. Remove it when you copy it to your page.
body {
height: 100vh;
margin: 0;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
}
.loader {
position: relative;
height: 30vh;
width: 50vw;
min-width: 200px;
min-height: 100px;
border: 1px solid #444; // added to see the responsiveness
}
.circle {
width: 55px;
height: 55px;
bottom: calc(40% - 27.5px);
left: -2px;
position: absolute;
border: 5px solid white;
border-radius: 50%;
}
h1 {
color: #fff;
position: absolute;
left: 75px;
bottom: 32%;
}
.progress {
position: absolute;
width: calc(100% - 60px);
height: 8px;
bottom: 40%;
left: 60px;
background: rgba(255, 255, 255, 0.5);
overflow: hidden;
}
.progress:after {
content: '';
display: block;
width: 100%;
height: 8px;
background: #fff;
animation: load 5s linear;
}
#-moz-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-webkit-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#-o-keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
#keyframes load {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
<div class="loader">
<!--<div class="logo"> </div>-->
<!--<img class="img-logo" src="https://openclipart.org/download/256338/whitecircle.svg">-->
<div class="circle"></div>
<h1 class="title">Loading</h1>
<div class="progress"></div>
</div>