Progress Bar Sizing - css

I am attempting to size the progress bar to be 300px x 300px but it keeps cutting off the top of the circle and the text at the bottom.
It should look like this:
But it looks like this after my code:
What should I adjust based on my code? Have tried to adjust the height and width of multiple containers but still no luck.:
#progress-bar {
position: absolute;
left: 50%;
top: 55%;
transform: translate(-51%, -50%);
width: 40%;
}
.container {
position: relative;
width: 100%;
display: flex;
justify-content: space-around;
}
.container .card {
position: relative;
width: 300px;
display: flex;
justify-content: center;
align-items: center;
height: 300px;
border-radius: 4px;
text-align: center;
overflow: hidden;
transition: 0.5s;
}
.container .card:before {
content: '';
position: absolute;
top: 0;
left: -50%;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.03);
pointer-events: none;
z-index: 1;
}
.percent {
position: relative;
width: 300px;
height: 300px;
border-radius: 50%;
box-shadow: inset 0 0 50px #000;
background: #222;
z-index: 1000;
}
.percent .number {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
.percent .number h2 {
color: #777;
font-weight: 700;
font-size: 40px;
transition: 0.5s;
}
.card:hover .percent .number h2 {
color: #fff;
font-size: 60px;
}
.percent .number h2 span {
font-size: 24px;
color: #777;
transition: 0.5s;
}
.card:hover .percent .number h2 span {
color: #fff;
}
.text {
position: relative;
color: #777;
margin-top: 20px;
font-weight: 700;
font-size: 18px;
letter-spacing: 1px;
text-transform: uppercase;
transition: 0.5s;
}
svg {
position: relative;
width: 150px;
height: 150px;
z-index: 1000;
}
svg circle {
width: 100%;
height: 100%;
fill: none;
stroke: #191919;
stroke-width: 10;
stroke-linecap: round;
transform: translate(5px, 5px);
}
svg circle:nth-child(2) {
stroke-dasharray: 440;
stroke-dashoffset: 440;
}
.card:nth-child(1) svg circle:nth-child(2) {
stroke-dashoffset: calc( 440 - (440 * 90) / 100);
/* use to adjust progress bar */
stroke: #00ff43;
}
<div id="feedbox-mid">
<div id="progress-bar">
<div class="container">
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>90<span>%</span></h2>
</div>
</div>
<h2 class="text">Html</h2>
</div>
</div>
</div>
</div>
</div>

I increased the width and height in .container .card. to 400px each.

Related

How to Center a Row of 3 Icons in the Middle of a Popup Modal?

I am having trouble centering a row of 3 social media icons in the middle of my popup modal and have it actually be responsive.
My failed method is adjusting the icons' "left" property by individual percentages..
Every time I think I have it centered, I test it out on a different screen size and it's too much to the right or too much to the left.
<section class="popup-modal">
<div class="popup-box">
<div class="popup-image-container">
<div class="popup-img">
</div>
</div>
<div class="popup-content">
<div class="popup-close">×</div>
<h1>FOLLOW US ON SOCIAL MEDIA</h1>
<p>#gravitasdesign</p>
<h3>Learn about our current and upcoming projects.</h3>
<i id="popup-facebook" class="bi bi-facebook"></i>
<i id="popup-instagram" class="bi bi-instagram"></i>
<i id="popup-linkedin" class="bi bi-linkedin"></i>
</div>
</div>
</section>
.popup-modal{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1099;
background-color: rgba(0, 0, 0, 0.8);
visibility: hidden;
opacity: 0;
transition: all 0.5s ease;
}
.popup-modal.show {
visibility: visible;
opacity: 1;
}
.popup-box {
background-color: #fff;
width: 750px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-wrap: wrap;
border-radius: 2.5px;
}
.popup-image-container{
flex: 0 0 50%;
max-width: 50%;
position: relative;
overflow: hidden;
}
.popup-img {
position: absolute;
width: 100%;
height: 100%;
background-image: url(images/popupmodal.jpg);
background-size: cover;
background-position: left;
animation: zoomInOut 50s linear infinite;
}
#keyframes zoomInOut{
0%,100%{
transform: scale(1);
}
50%{
transform: scale(1.2);
}
}
.popup-content {
flex: 0 0 50%;
max-width: 50%;
padding: 30px;
}
.popup-content h1{
font-family: interstate, sans-serif;
font-weight: 700;
font-style: normal;
font-size: 36px;
text-align: center;
line-height: 55px;
word-spacing: 4px;
color: #300600;
}
.popup-content h3{
font-family: interstate, sans-serif;
font-weight: 500;
font-style: normal;
font-size: 24px;
text-align: center;
line-height: 40px;
color: #300600;
padding-bottom: 35px;
}
.popup-content p {
font-family: 'interstate', sans-serif;
font-weight: 700;
padding-top: 30px;
padding-bottom: 35px;
text-align: center;
font-size: 28px;
line-height: 42.5px;
color: #300600;
}
#popup-facebook, #popup-instagram, #popup-linkedin{
position: relative;
left: 9.5%;
font-size: 32px;
margin-right: 24px;
margin-left: 24px;
transition: 0.2s ease-in-out;
}
#popup-facebook{
color: #4267B2;
}
#popup-linkedin{
color: #0077b5;
}
#popup-instagram {
color: #0077b5;
}
.popup-close {
font-size: 32px;
position: absolute;
left: 96%;
top: 1%;
cursor: pointer;
transition: 0.2s ease-in-out;
color: #300600;
}
Here you can try this logic
#popup-facebook,
#popup-instagram,
#popup-linkedin {
position: relative;
left: 9.5%;
font-size: 32px;
margin-right: 24px;
margin-left: 24px;
transition: 0.2s ease-in-out;
}
#popup-facebook {
color: #4267b2;
}
#popup-linkedin {
color: #0077b5;
}
#popup-instagram {
color: #0077b5;
}
.popup-close {
font-size: 32px;
position: absolute;
left: 96%;
top: 1%;
cursor: pointer;
transition: 0.2s ease-in-out;
color: #300600;
}
.popup-content {
display: flex;
flex-direction: column;
}
.icons-box {
display: flex;
justify-content: center;
}
<section class="popup-modal">
<div class="popup-box">
<div class="popup-image-container">
<div class="popup-img"></div>
</div>
<div class="popup-content">
<div class="popup-close">×</div>
<h1>FOLLOW US ON SOCIAL MEDIA</h1>
<p>#gravitasdesign</p>
<h3>Learn about our current and upcoming projects.</h3>
<div class="icons-box">
<i id="popup-facebook" class="bi bi-facebook"></i>
<a href="#">
<i id="popup-instagram" class="bi bi-instagram"></i
></a>
<i id="popup-linkedin" class="bi bi-linkedin"></i>
</div>
</div>
</div>
</section>
:
Any particular reason why you are not using display: flex to center the icons? I would create a div container to hold the icons and set that to display: flex; with justify-content: center; (or you can play around other justify-content values to match your expected output).

Hover event not working with biggest z-index

I have a gallery item with some image in its body. It has to display MORE link in the center of the body when I hover over gallery item (which works just fine) and display 0.5 opacity when I hover over MORE link. Even though z-index is bigger than parent's, for some reason :hover event simply does not fire. Any clue on how to fix this? My cursor: pointer also does not work.
HTML:
<div class="gallery _flex-between">
<div class="gallery__item gallery-item _flex-column-center">
<div class="gallery-item__body">
<div class="gallery-item__more-container">
<a class="gallery-item-more">More →</a>
</div>
<img src="/resources/projects/1.jpg" alt="" class="gallery__img">
</div>
<div class="gallery-item__footer">
Everlasting Summer
</div>
</div>
</div>
CSS:
._absolute-cover {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.gallery {
margin-top: 4em;
width: 90%;
}
.gallery-item__footer {
font-size: 1.6rem;
margin-top: 1em;
width: 100%;
border: 1px solid black;
text-align: center;
border-radius: 35px;
padding: .5em 0;
letter-spacing: 2px;
background-color: white;
transition: background-color .3s, color .3s;
}
.gallery__item {
position: relative;
width: 30%;
max-width: 600px;
}
.gallery-item__more-container {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0);
transition: background-color .3s;
border-radius: 35px;
z-index: 2;
}
.gallery-item__link {
position: absolute;
width: 100%;
height: 100%;
cursor: default;
z-index: 4;
}
.gallery-item-more {
position: relative;
z-index: 1000000000;
width: 50%;
background-color: rgba(255, 255, 255, 1);
opacity: 0;
transition: background-color .3s;
color: black;
font-weight: bold;
letter-spacing: 1px;
padding: 1em 0;
border-radius: 35px;
text-align: center;
cursor: pointer;
}
.gallery-item-more:hover {
background-color: rgba(255, 255, 255, .5);
}
.gallery-item__link:hover ~ .gallery-item__footer {
background-color: black;
color: white;
}
.gallery-item__link:hover ~ .gallery-item__body .gallery-item__more-container {
background-color: rgba(0,0,0,0.8);
}
.gallery-item__link:hover ~ .gallery-item__body .gallery-item-more {
opacity: 1;
}
.gallery-item__body {
width: 100%;
position: relative;
}
._flex-column-center {
display: flex;
flex-direction: column;
align-items: center;
}
.gallery__img {
object-position: top;
height: 25vw;
width: 100%;
border-radius: 35px;
}
Move the image before the more-button and it should work: Codepen
<div class="gallery _flex-between">
<div class="gallery__item gallery-item _flex-column-center">
<div class="gallery-item__body">
<img src="/resources/projects/1.jpg" alt="" class="gallery__img">
<div class="gallery-item__more-container">
<a class="gallery-item-more">More →</a>
</div>
</div>
<div class="gallery-item__footer">
Everlasting Summer
</div>
</div>
</div>

Fade one element out while fade in background element on hover

I want to fade out a text placed on an image on hover and fade in another from the background.
So far the fade out part is working, but the fade in part not. See "run code snippet".
I want fade out the first text completely but not fully cover the background image which is why the opacity of:
location-wrapper { background-color: rgba(0, 0, 0, 0.6);}
is set to 0.6 and:
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
set to 0.7.
If I set the opacity of the background text to 1, I can see the background text is there, but the transition on hover to blend it in is not working. I guess because the div is in the background and the hover of the first div is triggered and not the hover option of the background?
.location-container {
position: relative;
height: 200px;
width: 100%;
color: white;
}
.location-bg-image {
position: absolute !important;
width: 100%;
height: 100%;
background-color: transparent;
z-index: -1;
}
.location-wrapper {
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
position: absolute;
width: 100%;
height: 100%;
z-index: 10;
opacity: 1;
transition: 2s;
}
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
.location-overlay {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.location-city {
padding-bottom: 60px;
color: white;
font-size: 25px;
font-weight: 400;
}
.location-text-wrapper {
height: 100%;
padding-top: 40px;
width: 100%;
opacity: 1;
transition: 5s;
display: flex;
flex-direction: column;
-ms-flex-align: center;
align-items: center;
justify-content: center;
}
.location-text-wrapper:hover {
opacity: 1;
}
.location-text {
color: white;
font-size: 18px;
opacity: 0;
transition: 5s
}
.location-text:hover {
opacity: 1;
}
<div class="location-container">
<Image class="location-bg-image" src="https://via.placeholder.com/150/000000/FFFFFF/"/>
<div class="location-wrapper has-bg-image">
<div class="location-overlay">
<div class="location-city">ExampleCity</div>
</div>
</div>
<div class="location-text-wrapper">
<div class="location-text">ExampleBackgroundText</div>
</div>
</div>
You don't need to have a separate .location-text-wrapper. I've changed your HTML a bit in the snippet below. I've inserted .location-text inside .location-overlay, and on .location-wrapper:hover I'm updating the value of opacity for .location-city and .location-text. This will give you the behaviour that you desire.
.location-container {
position: relative;
height: 200px;
width: 100%;
color: white;
}
.location-bg-image {
position: absolute !important;
width: 100%;
height: 100%;
background-color: transparent;
z-index: -1;
}
.location-wrapper {
background-color: rgba(0, 0, 0, 0.6);
text-align: center;
position: absolute;
width: 100%;
height: 100%;
z-index: 10;
opacity: 1;
transition: 2s;
}
.location-wrapper:hover {
background-color: rgb(255, 255, 255);
opacity: 0.7;
}
.location-overlay {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 1
}
.location-city {
padding-bottom: 60px;
color: white;
font-size: 25px;
font-weight: 400;
opacity: 1;
transition: 5s;
}
.location-wrapper:hover .location-city {
opacity: 0;
}
.location-wrapper:hover .location-text {
opacity: 1;
}
.location-text {
color: black;
font-size: 18px;
opacity: 1;
transition: 5s
}
<div class="location-container">
<Image class="location-bg-image" src="https://via.placeholder.com/150/000000/FFFFFF/"/>
<div class="location-wrapper has-bg-image">
<div class="location-overlay">
<div class="location-city">ExampleCity</div>
<div class="location-text">ExampleBackgroundText</div>
</div>
</div>
</div>

Elements child "shakes" when I increase the size with transition/animation

I have a circle here that increases with size when I hover over it. When I do that the "+" I have in the middle "shakes".
HTML
<div class='test-ani'>
<span>+</span>
</div>
CSS (SCSS)
.test-ani {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: cornflowerblue;
user-select: none;
cursor: pointer;
&:hover {
transition: .5s;
width: 120px;
height: 120px;
}
span {
color: #ffdb58;
font-size: 50px;
padding: 0;
margin: 0;
}
}
VISUAL GIF
Animate transform rule:
section {
position: relative;
width: 100%;
height: 100%;
}
.test-ani {
position: absolute;
top: 50%;
left: 50%;
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: cornflowerblue;
user-select: none;
cursor: pointer;
}
.test-ani:hover {
transition: transform .5s;
transform: scale(1.2);
}
.test-ani span {
color: #ffdb58;
font-size: 50px;
padding: 0;
margin: 0;
}
<section>
<div class='test-ani'>
<span>+</span>
</div>
</section>

Border CSS, colour a certain percentage

I want to achieve this effect:
You see that the orange colour is only 35% of the whole border. How can I do this?
HTML:
<div id="test">
<h1> hello</h1>
</div>
CSS:
h1 {
line-height: 80px;
font-size: 20px;
font-family: Arial;
}
#test {
margin: auto;
text-align: center;
border-radius: 50%;
height: 80px;
width: 80px;
border: 5px solid black;
}
Here's one way to do it with svg and some trickery using stroke dash array offsets.
http://codepen.io/flurrd/pen/zZyrBx?editors=1100
<div class="container">
<h1>50%</h1>
<svg
x="0px"
y="0px"
viewBox="0 0 397.6 435.3"
enable-background="new 0 0 397.6 435.3"
xml:space="preserve"
class="svg"
>
<circle
class="circle-bg"
cx="198.3"
cy="217.3"
r="139.2"
transform="rotate(270 198.3 217.3)"
/>
<circle
class="circle"
cx="198.3"
cy="217.3"
r="139.2"
transform="rotate(270 198.3 217.3)"
/>
</svg>
</div>
SCSS
body{
display: flex;
justify-content: center;
align-items: center;
}
//circumference = 2πr
// svg circle radius is 139
$pi: 3.14159265358979;
$Twopi: $pi * 2;
$circumference: calc(#{$Twopi} * 139);
$arc-length-percent: 0.5;
.circle {
fill: none;
stroke-width: 10px;
stroke: tomato;
//0.5 - 50%
stroke-dasharray: calc(#{$arc-length-percent} * #{$circumference}) $circumference;
}
.circle-bg {
fill: none;
stroke-width: 10px;
stroke: grey;
}
//layout stuff
.container {
width: 300px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
h1 {
font-family: sans-serif;
}
svg {
position: absolute;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
Compiled CSS
body {
display: flex;
justify-content: center;
align-items: center;
}
.circle {
fill: none;
stroke-width: 10px;
stroke: tomato;
stroke-dasharray: calc(0.5 * calc(6.28319 * 139)) calc(6.28319 * 139);
}
.circle-bg {
fill: none;
stroke-width: 10px;
stroke: grey;
}
.container {
width: 300px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
h1 {
font-family: sans-serif;
}
svg {
position: absolute;
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
}

Resources