I want to make progress bar look like the image below by using CSS. How can i do for it?
what i expected
I try to do it already. What i have got is this.
what i have done
progress {
border: 1.5px solid silver;
border-radius: 0px;
width: 170px;
height: 18px;
}
progress::-webkit-progress-bar {
background-color: whitesmoke;
border-radius: 0px;
}
progress::-webkit-progress-value {
background-color: cornflowerblue;
border-radius: 0px;
}
<section class="prog">
<p>Progress of today's class <progress value="2" max="5"></progress></p>
</section>
You can add stripes in background.
Using linear gradient and % restricting #ececec color to 1.5% width and add white color as a fill up color.
progress {
border: 1.5px solid silver;
border-radius: 0px;
width: 170px;
height: 18px;
}
progress::-webkit-progress-bar {
background: linear-gradient(
to right,
white 10%,
#ececec 11% 11.5%,
white 11.5% 20%,
#ececec 20% 21.5%,
white 21.5% 30%,
#ececec 31% 31.5%,
white 31.5% 40%,
#ececec 41% 41.5%,
white 41.5% 50%,
#ececec 51% 51.5%,
white 51.5% 60%,
#ececec 60% 51.5%,
white 61.5% 70%,
#ececec 70% 71.5%,
white 71.5% 80%,
#ececec 80% 81.5%,
white 81.5% 90%,
#ececec 90% 91.5%,
white 10%
);
border-radius: 0px;
}
progress::-webkit-progress-value {
background-color: cornflowerblue;
border-radius: 0px;
}
<section class="prog">
<p>Progress of today's class
<progress value="2" max="5"></progress>
</p>
</section>
UPDATE:
As #Afif mentioned repeating-linear-gradient(), this method is a more concise & compact way to do the same thing as above. It is also supported in almost every browser.
progress {
border: 1.5px solid silver;
border-radius: 0px;
width: 170px;
height: 18px;
}
progress::-webkit-progress-bar {
background: repeating-linear-gradient(90Deg, white, white 9%, #ececec 10%);
border-radius: 0px;
}
progress::-webkit-progress-value {
background-color: cornflowerblue;
border-radius: 0px;
}
<section class="prog">
<p>Progress of today's class
<progress value="2" max="5"></progress>
</p>
</section>
::-webkit-progress-bar is non-standard and not recommended for production websites.
Ignoring that, the method of #Ahmed Ali suggested is correct, or you can also use a repeated background image to show your expected result.
To illustrate, I took a random vertical line from the internet, so in your case, you'll need to create a line of the color you want.
progress {
border: 1.5px solid silver;
border-radius: 0px;
width: 170px;
height: 18px;
}
progress::-webkit-progress-bar {
background-color: whitesmoke;
background-image: url('https://www.researchgate.net/profile/Kyriaki-Mikellidou/publication/264201750/figure/fig2/AS:288776888434689#1445861183969/The-vertical-horizontal-illusion-Although-of-equal-lengths-the-vertical-line-looks.png');
background-size: 20px;
background-repeat: repeat;
border-radius: 0px;
}
progress::-webkit-progress-value {
background-color: cornflowerblue;
border-radius: 0px;
}
<section class="prog">
<p>Progress of today's class <progress value="2" max="5"></progress></p>
</section>
Related
I could able to get progress bar with below code, but couldn't find solution how to add a small circle on the progress bar ?
HTML
<progress max="100" value="75"></progress>
CSS
progress {
width: 90%;
display: block; /* default: inline-block */
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
progress::-moz-progress-bar {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
progress::-webkit-progress-bar {
background: transparent;
}
progress::-webkit-progress-value {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
Add a second background using a radial-gradient
progress {
width: 90%;
display: block; /* default: inline-block */
margin-bottom:1em;
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
progress::-moz-progress-bar {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
progress::-webkit-progress-bar {
background: transparent;
}
progress::-webkit-progress-value {
border-radius: 12px;
background: radial-gradient(4px at 97%,white,white 4px,transparent),linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%))
;
}
<progress max="100" value="75"></progress>
<progress max="100" value="50"></progress>
<progress max="100" value="25"></progress>
I have no idea how to add a circle at the end of the progress element, but it is possible to do it with the div element
CSS:
.first{
width: 90%;
display: block; /* default: inline-block */
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
.second{
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
border-radius: 14px;
height: 10px;
width: 75%;
}
.third{
width: 10px;
background: linear-gradient(to right, hsl(0, 0%, 100%), hsl(0, 0%, 99%));
border-radius: 60px;
height: 8px;
width: 8px;
margin: 1px;
margin-right: 1px !important;
float: right;
margin-right: 0px;
color: white;
}
HTML:
<div class="first">
<div class="second">
<div class="third">.</div>
</div>
</div>
I want to create a zig-zag border in css which is responsive, i.e. the zig-zag border must adjust itself to fit perfectly according to width of the container.
I was able to create this:
But on changing the width it's output is :
I want to perfectly fit the zig-zag pattern like above image on changing the width of the container.
It would be helpful if I could also add some radius at peak points like this :
Here is the code so far
.container {
width: 664px;
}
.sub-container {
border: 2px solid black;
border-bottom: 0;
padding: 40px;
height: 200px;
}
.upper-zigzag {
background: linear-gradient(135deg, #ffffff 25%, transparent 25%) 0px 0,
linear-gradient(225deg, #ffffff 25%, transparent 25%) 0px 0;
background-size: 60px 60px;
background-color: black;
height: 32px;
background-repeat: repeat-x;
border-left: 2px solid black;
border-right: 2px solid black;
}
.lower-zigzag {
position: relative;
background:
linear-gradient(315deg, #ffffff 25%, transparent 25%) -28px -30px,
linear-gradient(45deg, #ffffff 25%, transparent 25%) -28px -30px;
background-size: 60px 60px;
background-color: transparent;
height: 30px;
background-repeat: repeat-x;
margin-top: -30px;
z-index: 1;
}
<div class="container">
<div class="sub-container"></div>
<div class="upper-zigzag"></div>
<div class="lower-zigzag"></div>
</div>
Thanks!
I want to draw the below ripple using css.
The closest I darw was something like this.
display: block;
width: 126px;
height: 180px;
background-color: rgba(99, 83, 196, 0.38);
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
Does anyone have an idea on how to draw a half ripple ?
I think it is just two concentric circles that are masked by the rounded rectangle. You can achieve this with a circular gradient background:
#out {
background: #ddd;
padding: 10px;
width: 200px;
}
#in {
background: #fff;
background: radial-gradient(circle at 180px 10px, rgba(146,136,193,1) 30px, rgba(183,178,214,1) 30.5px, rgba(183,178,214,1) 50px, rgba(255,255,255,1) 50.5px);
background-repeat: no-repeat;
border-radius: 8px;
color: #6456BD;
font-family: sans-serif;
font-size: 20px;
font-weight: 700;
height: 40px;
padding: 30px 20px;
}
<div id="out">
<div id="in">
Usage<br>balances
</div>
</div>
I've been trying to make responsive colored eye focus icon, but so far all I've tried has been unsuccessful.
I was trying to somewhat replicate the colors of a real eye.
I used border, box shadow, to get the colors, but that part is not scaling. Tried with outline too, but failed as well, that one wasn't even round.
The height of the div is currently static, but I would like it to be responsive. So the whole eye scales properly across different sizes.
Here's my code:
<div class="paragraph eye-focus">
<div class="eye1" width="80%">
<div class="eye2"></div>
</div>
</div>
.eye1 {
height: 200px;
height: calc(attr(width) / 2.5);
width: 75%;
background-color: white;
border-radius: 50%;
position: relative;
margin: auto;
}
.eye2 {
background-color: black;
width: 8%;
height: 12%;
border-radius: 50%;
border: 0.5em solid #a50;
box-shadow: 0 0 0 1.5em #080;
position: absolute;
top: 40%;
left: 45%;
}
.eye-focus {
position: relative;
}
jsfiddle if you'd prefer https://jsfiddle.net/xcxdp92q/
I'd like to put my solution out there.
You can use background radial-gradient to create the eye in a single element.
When adding padding in %, it is based on the width of the element. Use that to your advantage to make it responsive. If padding equals width, the element will be a square.
.eye-focus {
box-sizing: content-box;
height: 0;
width: 75%;
padding: 30% 0 0 0;
margin: 0 auto;
border-radius: 50%;
background-color: #fff;
background-image: radial-gradient(circle, #000 8%, #a50 8%, #0b0 17%, #080 33%, transparent 33%);
}
<div class="paragraph">
<div class="eye-focus"></div>
</div>
jsfiddle
If you're only supporting browsers that support gradients (and current browsers most do) then you can just use one div and do all the colors in a radial gradient. I used vw to size it like Suthan Bala suggested in their comment.
body {
background: #EEE;
}
.eye {
border-radius: 50%;
background: -moz-radial-gradient(center, ellipse cover, #000000 17%, #aa5500 18%, #008800 40%, #ffffff 41%);
background: -webkit-radial-gradient(center, ellipse cover, #000000 17%, #aa5500 18%, #008800 40%, #ffffff 41%);
background: radial-gradient(ellipse at center, #000000 17%, #aa5500 18%, #008800 40%, #ffffff 41%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff', GradientType=1);
width: 35vw;
height: 35vw;
}
<div class="eye">
</div>
I used the Color Gradient Generator by Colorzilla.
Try using this CSS:
.eye1 {
height: 4vw;
width: 4vw;
background-color: white;
border-radius: 50%;
position: relative;
margin: auto;
}
.eye2 {
background-color: black;
width: 6vw;
height: 6vw;
border-radius: 50%;
border: 1em solid #a50;
box-shadow: 0 0 0 3vw #080;
position: relative;
top: 8vw;
left: 43%;
}
.eye-focus {
position: relative;
}
I've been using vw a lot lately (for a year now). Very handy!
Below is the image I am trying for, I managed to get a square using CSS, but I am trying for horizontal and vertical line in a square.
.hub{
width: 119px;
height: 101px;
background: #b5adad;
}
<div class="hub"></div>
There are many ways to do this and one would be to use gradients like below: (the image in question was actually a rectangle.)
The approach is very simple - we use 2 linear gradients to create two thin solid colored lines and then position the images such that they match our needs. Linear gradients are used even though it creates only a solid color because it is easier to control size and position of an image than background color.
div {
height: 100px;
width: 200px;
border: 1px solid red;
background-image: linear-gradient(to bottom, red, red), linear-gradient(to right, red, red);
background-repeat: no-repeat;
background-size: 1px 100%, 100% 1px;
background-position: 20px 0px, 0px 10px;
}
<div></div>
We can also create an output which has a fade-out or shadow effect like in the image in question:
div {
height: 100px;
width: 200px;
border: 1px solid;
background-color: gray;
background-image: linear-gradient(to bottom, black, black), linear-gradient(to right, red, transparent), linear-gradient(to right, black, black), linear-gradient(to bottom, red, transparent);
background-repeat: no-repeat;
background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
background-position: 20px 0px, 21px 0px, 0px 10px, 0px 11px;
box-shadow: inset 0px 0px 3px red;
}
<div></div>
Another way is to use :before and :after pseudo-elements:
.hub{
width: 119px;
height: 101px;
background: #b5adad;
position: relative;
padding: 18px 0 0 18px;
}
.hub:after, .hub:before {
content: " ";
background: black;
display: block;
position: absolute;
}
.hub:after {
width: 1px;
height: 100%;
left: 15px;
top: 0;
}
.hub:before {
width: 100%;
height: 1px;
top: 15px;
left: 0;
}
<div class="hub">Lorem ipsum dolor amet</div>