I want it to be like this shape .
Just tell me how to make the not completed borders.
And one last thing is that I have to use one div.<div>Elzero</div> with pseudo-elements
Thanks in advance.
you can make it with transparent border
div
{
background-color: #ddd;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 30px;
margin: 40px auto;
color: black;
width: 200px;
height: 200px;
border-radius: 50%;
position: relative;
}
div::before
{
content: "";
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
left: 0;
top: 0;
transform: translate(-10px, -10px);
z-index: -1;
border: 10px solid;
border-color: red red red transparent;
}
body ::after
{
content: "";
width: 220px;
height: 220px;
border-radius: 50%;
position: absolute;
left: 0;
top: 0;
transform: translate(-21px, -22px);
z-index: -8;
border: 12px solid;
background: transparent;
border-color: blue transparent blue blue;
}
<div></div>
Try That Bro :)
div {
background-color: #eee;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 30px;
margin: 50px auto;
height: 200px;
width: 200px;
border-radius: 50%;
position: relative;
}
div::before{
content: "";
height: 200px;
width: 200px;
border-radius: 50%;
border: 10px solid #03a9f4;
border-left-color: transparent;
position: absolute;
top: 0;
left: 0;
transform: translate(-10px, -10px);
z-index: -1;
transition: transform 0.5s linear;
}
div:hover::before{
transform: translate(-10px, -10px) rotate(360deg);
}
div::after {
content: "";
height: 220px;
width: 220px;
border-radius: 50%;
border: 10px solid #e91e63;
border-right-color: transparent;
position: absolute;
top: 0;
left: 0;
transform: translate(-20px, -20px);
z-index: -2;
transition: transform 0.5s 0.5s linear;
}
div:hover::after{
transform: translate(-20px, -20px) rotate(360deg);
}
Just put the text/string 'HERE' in a anchor tag like this:
HERE
Related
I have this loading animation.but after every rotation it stops for a split second.is there a way to make it more fluid...im using after and before pseduo elements and animating the parent circle with animation-iteration-count to infinite.i am rotating it 405deg=45deg(intial value)+360deg
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color:#1A4D2E ;
}
.circle{
width: 40px;
height: 40px;
border-radius: 50%;
margin-right:5px ;
border-top: 1.5px solid#350cc9;
fill:none;
transform: rotate(45deg);
position: relative;
animation: loadanim 1.5s;
animation-iteration-count: infinite;
}
.circle::before{
content: "";
position: absolute;
top:2px;
left: 5px;
width: 30px;
height:30px;
border-radius: 50%;
margin-right:5px ;
border-top: 1.5px solid#f1f513;
fill:none;
transform: rotate(20deg);
}
.circle::after{
content: "";
position: absolute;
top:6px;
left: 8px;
width: 25px;
height:25px;
border-radius: 50%;
margin-right:5px ;
border-top: 1.5px solid#f30ed4;
fill:none;
transform: rotate(20deg);
}
#keyframes loadanim{
from{
transform: rotate(45deg);
}
to{
transform: rotate(405deg);
}
}
<body>
<div class="circle"></div>
</body>
It's not completely stopping, but it's easing (the animation-timing-function). If you set it to use linear instead then it is continuous.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #1A4D2E;
}
.circle {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 5px;
border-top: 1.5px solid#350cc9;
fill: none;
transform: rotate(45deg);
position: relative;
animation: loadanim 1.5s linear;
animation-iteration-count: infinite;
}
.circle::before {
content: "";
position: absolute;
top: 2px;
left: 5px;
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 5px;
border-top: 1.5px solid#f1f513;
fill: none;
transform: rotate(20deg);
}
.circle::after {
content: "";
position: absolute;
top: 6px;
left: 8px;
width: 25px;
height: 25px;
border-radius: 50%;
margin-right: 5px;
border-top: 1.5px solid#f30ed4;
fill: none;
transform: rotate(20deg);
}
#keyframes loadanim {
from {
transform: rotate(45deg);
}
to {
transform: rotate(405deg);
}
}
<body>
<div class="circle"></div>
</body>
I was told they should not be in there, but how do I remove them?
https://jsfiddle.net/jqzs6d3o/
That is all I am doing in the code.
Removing the <b> </b> tags from the html it.
How would that be done?
Is this something hard to do?
Removing <b></b> removes the blue circle. I want to keep the circle and remove <b></b>
<button class="exitnew" type="button" aria-label="Close"><b></b></button>
.exitnew {
-webkit-appearance: none;
appearance: none;
position: relative;
box-sizing: border-box;
margin: auto;
padding: 0;
width: 48px;
height: 48px;
cursor: pointer;
background: transparent;
border: none;
border-radius: 50%;
clip-path: circle(50%);
transition: all 1s ease;
overflow: hidden;
}
.exitnew::before,
.exitnew::after {
content: "";
position: absolute;
height: 5px;
width: 38px;
top: 22px;
left: 5px;
right: 5px;
background: red;
transform: rotate(45deg);
transition: all 1s ease;
}
.exitnew::after {
transform: rotate(-45deg);
}
.exitnew:hover {
background: transparent;
}
.exitnew:hover::before,
.exitnew:hover::after {
background: green;
}
.exitnew b {
box-sizing: border-box;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
border: 5px solid blue;
border-radius: 50%;
}
<button class="exitnew" type="button" aria-label="Close"><b></b></button>
Added some styles #circle ID and changed your positioning a bit of .exitnew Also made b display: none; Check the changes below.
.exitnew {
-webkit-appearance: none;
appearance: none;
position: relative;
box-sizing: border-box;
margin: auto;
padding: 0;
width: 48px;
height: 48px;
cursor: pointer;
background: transparent;
border: none;
border-radius: 50%;
clip-path: circle(50%);
transition: all 1s ease;
overflow: hidden;
}
.exitnew::before,
.exitnew::after {
content: "";
position: absolute;
height: 5px;
width: 38px;
top: 17px;
left: -1px;
right: 5px;
background: red;
transform: rotate(45deg);
transition: all 1s ease;
}
.exitnew::after {
transform: rotate(-45deg);
}
.exitnew:hover {
background: transparent;
}
.exitnew:hover::before,
.exitnew:hover::after {
background: green;
}
.exitnew b {
display: none;
box-sizing: border-box;
position: relative;
width: 100%;
height: 100%;
border: 5px solid blue;
border-radius: 50%;
}
#circle {
background-color:#fff;
border-width: 2rem;
border:4px solid darkblue;
height:45px;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
width: 45px;
margin-left: 1rem;
position: absolute;
}
<button class="exitnew" id="circle" type="button" aria-label="Close"><b></b></button>
You can utilize the button itself as the circle.
With this you’ll have cleaner code where you can just completely remove b tag without losing the circle.
.exitnew {
box-sizing: border-box;
position: absolute;
left: 0;
top: 0;
width: 38px;
height: 40px;
border: 5px solid blue;
border-radius: 50%;
}
Here’s the changes I made.
https://jsfiddle.net/Lnbuxvc0/
I am trying to achieve this
But so far I managed to do this
I am not able to position the transformed square to the left, and I dont know how to create the outer border.
I thought of adding a margin to it but it did not work.
:root {
--primary: #0098fa;
--accent: #effaff;
--dark: #394e67;
--darker: #2f3640;
}
.ts-divider {
position: absolute;
z-index: 1;
width: 21px;
height: 21px;
transform: translateY(100%);
color: var(--primary);
}
.ts-divider:after {
content: '';
position: absolute;
z-index: 1;
width: 100px;
height: 1px;
top: 10px;
background-color: currentColor;
opacity: .6;
}
.ts-divider span:before {
width: 70.75%;
height: 70.75%;
left: 3px;
top: 3px;
border: 1px solid var(--darker);
}
.ts-divider span::after {
width: 41%;
height: 41%;
left: 6px;
top: 6px;
background-color: var(--darker);
content: '';
position: absolute;
z-index: 1;
transform: rotate3d(0, 0, 1, 45deg);
border: 1px solid var(--primary);
}
<span class="ts-divider">
<span></span>
</span>
You can make use of box-shadow property to have multiple borders. You can also remove the z-index on the :after pseudo element. I have highlighted the changes through comments.
:root {
--primary: #7a6450;
--accent: #effaff;
--dark: #7a6450;
--darker: #7a6450;
}
body {
background: #0e1317;
display: flex;
justify-content: center;
}
.ts-divider {
position: absolute;
z-index: 1;
width: 63px;
height: 63px;
transform: translateY(100%);
color: var(--primary);
}
.ts-divider:after {
content: '';
position: absolute;
/* z-index: 1; Removed */
width: 100px;
height: 5px;
top: 17.5px; /* Manual adjustment according to your code */
background-color: currentColor;
opacity: .6;
}
.ts-divider span:before {
width: 70.75%;
height: 70.75%;
left: 3px;
top: 3px;
border: 1px solid var(--darker);
}
.ts-divider span::after {
width: 41%;
height: 41%;
left: 6px;
top: 6px;
background-color: var(--darker);
content: '';
position: absolute;
z-index: 1;
transform: rotate3d(0, 0, 1, 45deg);
border: 1px solid var(--primary);
box-shadow: 0 0 0 5px #0e1317, 0 0 0px 10px var(--darker); /* First box-shdoaw with the background color and second one with the box color. 5 and 10 are values of their spread radius so you can make use of the offset using that. */
}
<span class="ts-divider">
<span></span>
</span>
I'll leave my attempt using single element with background and border color:
:root {
--primary: #0098fa;
--accent: #effaff;
--dark: #394e67;
--darker: #2f3640;
--line-length: 200px;
--box-size: 40px;
--inner-box-size: 24px;
--spacing: calc( var(--box-size) - var(--inner-box-size));
--offset: calc( var(--spacing) / 2);
box-sizing: border-box;
}
.ts-divider {
position: relative;
width: var(--line-length);
height: var(--box-size);
border-bottom: 1px solid var(--primary);
}
.ts-divider::before {
content: '';
display: block;
width: var(--box-size);
height: var(--box-size);
position: absolute;
top: 50%;
left: 0;
border: 1px solid var(--primary);
background-color: var(--dark);
transform: rotate(45deg);
}
.ts-divider::after {
--top-offset: calc(50% + var(--offset));
content: '';
display: block;
width: var(--inner-box-size);
height: var(--inner-box-size);
position: absolute;
top: var(--top-offset);
left: var(--offset);
background-color: var(--primary);
transform: rotate(45deg);
}
<div class="ts-divider"></div>
How can I get rounded borders at the top and bottom of this curved line. Checkout the white line of this picture, that is what I want to achieve with CSS. Something like this
My Snippet:
.curved-line {
position: absolute;
width: 180px;
height: 90px;
border: solid 12.5px #000;
border-color: black transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
}
<div class="curved-line"></div>
Use :before & :after pseudo elements.
.curved-line:before {
content: '';
position: absolute;
top: 95%;
left: -12px;
width: 12.5px;
height: 12.5px;
border-radius: 50%;
background: black;
}
.curved-line:after {
content: '';
position: absolute;
top: 95%;
right: -11.5px;
width: 12.5px;
height: 12.5px;
border-radius: 50%;
background: black;
}
Have a look at the snippet below:
.curved-line {
position: absolute;
width: 180px;
height: 90px;
border: solid 12.5px #000;
border-color: black transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
position: relative;
}
.curved-line:before {
content: '';
position: absolute;
top: 95%;
left: -12px;
width: 12.5px;
height: 12.5px;
border-radius: 50%;
background: black;
}
.curved-line:after {
content: '';
position: absolute;
top: 95%;
right: -11.5px;
width: 12.5px;
height: 12.5px;
border-radius: 50%;
background: black;
}
<div class="curved-line"></div>
Hope this helps!
You can use pseudoelements before and after the curved-line class.
.curved-line {
position: relative;
width: 180px;
height: 90px;
border: solid 12.5px #000;
border-color: black transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
}
.curved-line:before {
content: '';
position: absolute;
left: 99%;
top: 91%;
background-color: black;
width: 13px;
height: 13px;
border-radius: 50%;
}
.curved-line:after {
content: '';
position: absolute;
left: -7%;
top: 91%;
background-color: black;
width: 13px;
height: 13px;
border-radius: 50%;
}
<div class="curved-line"></div>
var c = document.getElementById("curvedLine");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.bezierCurveTo(20, 140, 170, 140, 170, 20);
ctx.lineWidth = 10; //width of the line
ctx.lineCap = 'round';
ctx.stroke();
<canvas id="curvedLine"></canvas>
You can also use canvas to do this task
You can make the borders rounded using css pseudo class.
.curved-line {
position: absolute;
width: 180px;
height: 90px;
border: solid 12px #000;
border-color: black transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
}
.curved-line:after{
content: "";
width: 12px;
height: 12px;
border-radius: 50%;
background: #000;
position: absolute;
top: 86px;
display: block;
left: -11px;
}
.curved-line:before{
content: "";
width: 12px;
height: 12px;
border-radius: 50%;
background: #000;
position: absolute;
top: 86px;
display: block;
left: 179px;
}
<div class="curved-line"></div>
use befor and after , so you know use curved try to use 3 curved superimposed :)
.curved-line {
position: absolute;
width: 180px;
height: 100px;
/* background: black; */
border: solid 12.5px #000;
border-color: black transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
}
.curved-line:before {
content:'';
position: absolute;
width: 25px;
height: 25px;
left: 115px;
/* background: black; */
border: solid 12.5px #000;
border-color: white transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
}
.curved-line:after {
content:'';
position: absolute;
width: 25px;
height: 25px;
left: -74px;
/* background: black; */
border: solid 12.5px #000;
border-color: white transparent transparent transparent;
border-radius: 50%/100% 100% 0 0;
transform: rotate(180deg);
margin-left: 45px;
margin-top: 60px;
}
<div class="curved-line"></div>
I need to create 1 div element and in it I need to draw 2 triangles as 1
1) it must be up arrow
2) it must be down arror
but I need add them in 1 class
I understand that I can create 2 classes and then with margin connect them but I need only one class
this is a problem.
can I do this?
If you were looking to make This for design (rather than being functional), you could use pseudo elements:
div {
position: relative;
margin: 50px;
height: 100px;
width: 100px;
transform: rotate(45deg);
}
div:before {
content: "";
height: 40%;
width: 40%;
top: 0;
left: 0;
position: absolute;
border-top: 5px solid black;
border-left: 5px solid black;
transition: all 0.6s;
}
div:after {
content: "";
height: 40%;
width: 40%;
bottom: 0;
right: 0;
position: absolute;
border-bottom: 5px solid black;
border-right: 5px solid black;
transition: all 0.6s;
}
div:hover:before,
div:hover:after {
border-color: tomato;
}
<div></div>
If, however, you need this to be actually functional (i.e. to register if you need it to be 'pressable' - then you would need to use multiple elements since pseudo elements aren't distinguishable in the DOM for 'key pressing'):
div {
margin: 50px;
height: 100px;
width: 100px;
position: relative;
}
div .up {
position: absolute;
top: 0;
left: 50%;
height: 50%;
width: 50%;
transform-origin: top left;
transform: rotate(45deg);
border-left: 5px solid tomato;
border-top: 5px solid tomato;
transition: all 0.6s;
}
div .down {
position: absolute;
top: 45%;
left: -5%;
height: 50%;
width: 50%;
transform-origin: bottom right;
transform: rotate(45deg);
border-bottom: 5px solid tomato;
border-right: 5px solid tomato;
transition: all 0.6s;
}
div span:hover {
border-color: black;
}
<div>
<span class="up"></span>
<span class="down"></span>
</div>
You can create a square div and just rotate it 45 degrees using CSS transform. You can view a live demo of it at JSFiddle
<div class="diamond"></div>
<style>
.diamond {
width: 100px;
height: 100px;
background-color: red;
transform: rotate(45deg);
}
</style>