I already have a skill bar created on my page, but I was wondering if there was a way to animate it, so that when you scroll to that area the bar extends out from nothing to the full length of the bar. Here is my html for the bar:
<div id="skills_skill">
<div class="col-xs-12 col-md-4" id='skills_text'>
Example Skill
</div>
<div class="col-xs-12 col-md-8" id='skills_container'>
<div class="skills example">90%</div>
</div>
</div>
And here is the css:
#skills_text {
font-weight: bold;
border-right: 1px solid white;
}
.skills {
text-align: right;
padding-right: 20px;
line-height: 20px;
color: black;
border-radius: 20px;
}
.example {
width: 90%;
background-color: white;
}
I assume you use Bootstrap 4. I will use Bootstrap progress component for this example. This snippet code only for the progress bar animation. You should use javascript to keep track of your scroll position to trigger the animation. Please let me know if you need help
.progress-bar {
animation: progress 300ms ease-in-out;
animation-fill-mode: forwards;
}
#keyframes progress {
0% {
width: 0;
}
100% {
width: 100%;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="progress">
<div class="progress-bar" role="progressbar" aria- valuenow="25" aria-valuemin="0" aria-valuemax="100"> </div>
</div>
Related
Here I have two separate options - Friends and Service Providers. I want the black border to slide left and right smoothly on clicking any of the two options.
When I click on 'service providers', the black bottom border must slide smoothly towards right. When I click on 'Friends', it should slide smoothly towards left.
I want to achieve this with CSS transitions may be.
Kindly help! I shall be grateful.
.container {
max-width: 500px
}
.row {
background-color: #f4f4f4;
border-bottom: 1px solid #dbdbdb;
text-align: center;
border-right: 1px solid #dbdbdb;
margin: 0px;
}
.friends.active {
border-bottom: 1px solid black;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-6 col-sm-6 friends active">
<h6>Friends</h6>
</div>
<div class="col-6 col-sm-6 seller">
<h6>Service Providers</h6>
</div>
</div>
</div>
You can use the radio button hack to fake it. I would also just use another element as the one that moves.
.container {
max-width: 500px
}
.row {
background-color: #f4f4f4;
border-bottom: 1px solid #dbdbdb;
text-align: center;
border-right: 1px solid #dbdbdb;
margin: 0px;
}
span {
position: relative;
left: 0;
bottom: 0;
width: 50%;
border-bottom: 2px black solid;
transition: all .5s;
}
#friendBox:checked~span {
left: 0%;
}
#sellerBox:checked~span {
left: 50%;
}
input[type="radio"] {
position: absolute;
left: -100vw;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container">
<div class="row">
<input type="radio" id="friendBox" name="header"></input>
<input type="radio" id="sellerBox" name="header"></input>
<div class="col-6 col-sm-6 friends active">
<label for="friendBox">Friends</label>
</div>
<div class="col-6 col-sm-6 seller">
<label for="sellerBox">Service Providers</label>
</div>
<span></span>
</div>
</div>
You can place an HR in your row and then animate the position using margin-left. On hover use the general sibling selector ~ with pseudo :hover to select the HR element. Adding a transition to the HR with margin duration and ease will animate its margin when the element is hovered over.
.container {
max-width: 500px
}
.row {
background-color: #f4f4f4;
border-bottom: 1px solid #dbdbdb;
text-align: center;
border-right: 1px solid #dbdbdb;
margin: 0px;
height: 2.2rem; /* added to make more visually appealing */
}
.friends, .seller {
cursor: pointer; /* added to show these are links */
height: 1.2rem; /* added to make more visually appealing */
}
.friends:hover ~ hr {
margin-left: 0%; /* placement of HR should be below friends btn */
}
.seller:hover ~ hr {
margin-left: 50%; /* placement of HR should be below seller btn */
}
hr {
height: .15rem;
width: 50%; /* width will be width of row (block ~ 100%) / # of btns */
margin: 0;
background: black;
border: none;
transition: margin .3s ease-in-out; /* Transition for the margin movement */
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-6 col-sm-6 friends active">
<h4>Friends</h4>
</div>
<div class="col-6 col-sm-6 seller">
<h4>Service Providers</h4>
</div>
<hr />
</div>
</div>
Hi there can someone help me with this progress html element I need to be able to put a text value on the right side of the progress and depending the progress if decreases the text to go with that
progress {
-webkit-appearance: none;
}
progress::-webkit-progress-bar {
background-color: orange;
}
<progress value="60" max="100"></progress><br/>
<progress value="90" max="100"></progress>
I need it like this on the photo
You should use a custom progress bar or a library that has an option for that. here is an example of a custom progress bar. Use Javascript to control the width and the content of the before pseudo-element
.progress{
height:30px;
width:300px;
background-color:orange;
position:relative;
}
.progress::before{
position:absolute;
height:30px;
background:green;
content:'50%';// hrere you should add the text
top:0;
left:0;
width:50%;
display:flex;
color:white;
align-items:center;
justify-content:flex-end;
padding-right:10px;
}
<div class="progress"></div>
I have updated the progress bar using pure css. Lets try with this example and comment for further information.
progress {
-webkit-appearance: none;
}
progress::-webkit-progress-bar {
background-color: orange;
}
.progress-bar span {
position: absolute;
display: inline-block;
color: #fff;
text-align: right;
}
.progress-bar {
display: block;
position: relative;
width: 100%;
}
progress {
width: 100%;
}
<div class="progress-bar">
<span data-value="60" style="width: 60%;">60</span>
<progress value="60" max="100"></progress>
</div>
<div class="progress-bar">
<span data-value="90" style="width: 90%;">90</span>
<progress value="90" max="100"></progress>
</div>
You have to use bootstrap latest version and it has in-built css :
Example :
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
</div>
<br><br>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 15%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100">10%</div>
<div class="progress-bar bg-success" role="progressbar" style="width: 30%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100">20%</div>
<div class="progress-bar bg-info" role="progressbar" style="width: 20%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">30%</div>
</div>
You can do it with little bit of js and css.
I would personally avoid the progress element cause of cross-browser styling issues.
Third party libraries are good but they come with a significant cost.
The bloated css and js are sometimes not worth it.
Hope this helps.
<style>
.progress {
width: 100%;
position: relative;
background-color: orange;
}
.bar {
width: 0%;
height: 30px;
background-color: green;
text-align: center;
line-height: 30px;
color: black;
}
.bar-text {
position: absolute;
top: 0;
width: 100%;
height: 30px;
text-align: center;
line-height: 30px;
color: black;
}
</style>
<script>
function init() {
var bar = document.getElementById("bar");
var width = 0;
var id = setInterval(frame, 10);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
bar.style.width = width + '%';
document.querySelector('.bar-text').innerHTML = width * 1 + '%';
}
}
}
</script>
<div class="progress" id="progress">
<div class="bar" id="bar"></div>
<div class="bar-text">10%</div>
</div>
<br>
<button onclick="init()">Click Me</button>
I'm an IT student in year 11 and I am struggling with adding a slideshow of images to my website I'm working on, I have tried looking up solutions but I can't seem to find anything that fixes my problem.
When I run the webpage in chrome, everything appears to be there, but the images aren't contained in the slideshow container, they run down the page.
I'm afraid it might be a really simple solution as I am still learning, but I would really appreciate if someone is able to figure out what is wrong as this is due soon and I'm running out of options. I got the code from w3schools.
Below is the code in my html document:
<!-- Slideshow container -->
<div class="slideshow-container">
<!-- Full-width images with number and caption text -->
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="images/max_photos.jpg" style="width:100%"/>
<div class="text">Caption Text</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="images/max_chloe.jpg" style="width:100%"/>
<div class="text">Caption Two</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="images/pictures.jpg" style="width:100%"/>
<div class="text">Caption Three</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="images/trains.jpg" style="width:100%"/>
<div class="text">Caption Three</div>
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<!-- The dots/circles -->
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
And the css code:
* {box-sizing:border-box}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Hide the images by default */
.mySlides {
display: together;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through
*/
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor:pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
#-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
#keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
I've never posted to this site before, I hope I've included everything needed.
Have you added any JavaScript for this slideshow? I guess not. Probably you wanted to follow w3school.
You need to have JavaScript code to show one image at a time and hide others
You have a ready made example for the same code you have written follow the link:
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow
I am building a landing page with angular and in my third div from top I have some animations. First div occupies 100vh viewspace, another say 50 and then I have following div (all these divs represent individual components):
<div id="about" class="app-about-us-div-container">
<div class="onboarding-flow mdl-grid">
<div class="mdl-cell mdl-cell--4-col">
<div class="circle circle-1">
<i class="onboarding-icon material-icons">local_phone</i>
</div>
<div class="onboarding-text">
<p>Tell us your problem domain and we will customize our solution to meet your specific needs</p>
</div>
</div>
<div class="mdl-cell mdl-cell--4-col">
<div class="circle circle-2">
<i class="onboarding-icon material-icons">group</i>
</div>
<div class="onboarding-text">
<p>Engage your project stakeholders, end users without any time hassle to build together a clear product vision</p>
</div>
</div>
<div class="mdl-cell mdl-cell--4-col">
<div class="circle circle-3">
<i class="onboarding-icon material-icons">trending_up</i>
</div>
<div class="onboarding-text">
<p>Benefit from our analytics to understand your users and their vision for the product. Build Personas to take best design decisions and streamline important product features </p>
</div>
</div>
</div>
</div>
It's css:
.app-about-us-div-container{
position: relative;
height: 70vh;
text-align: center;
background-color: #ECEFF1;
}
.app-about-us-div-container h4{
margin-top: 0%;
padding-top: 20px;
}
.onboarding-flow {
align-content: center;
padding-top: 2%;
}
.circle {
display: inline-block;
width: 150px;
height: 150px;
box-sizing: border-box;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
border-radius: 75px;
background: transparent;
text-align: center;
border: 3px solid #cccccc;
animation-name: pop;
animation-iteration-count: 1;
animation-duration: 0.3s;
animation-direction: normal;
animation-fill-mode: forwards;
animation-timing-function: ease-in-out;
color: #cccccc;
}
.circle-1 {
animation-delay: 1s;
}
.circle-2 {
animation-delay: 2s;
}
.circle-3 {
animation-delay: 3s;
}
.onboarding-icon {
align-self: center;
font-size: 65px;
position: relative;
top: calc(50% - 35px);
}
.onboarding-text {
position: relative;
padding-top: 2%;
width: 60%;
left: 20%;
}
.onboarding-text p {
font-size: 17px;
}
#keyframes pop {
0% {
color: #F44336;
transform: scale(1);
}
50% {
color: #ffffff;
border-color: #F44336;
background-color: #F44336;
transform: scale(1.2);
}
100% {
color: #ffffff;
border-color: #EF5350;
background-color: #EF5350;
transform: scale(1);
}
}
Now the problem is animations are played on pageload and till the user reaches to this div it's over. How can I make sure that these animations are played when this div is in viewport or at the top of the screen (I am not sure what could be the best option as the div above occupies 50vh so at one point both of them are visible 50 50)? Is anular animation of any help in this case?
It's component:
#Component({
selector: 'app-about-us',
templateUrl: './about-us.component.html',
styleUrls: ['./about-us.component.css']
})
export class AboutUsComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
I used ng-in-viewport to achieve something similar to this. Follow the instructions available on the plugin's GitHub page:
1. Install the plugin
npm install --save ng-in-viewport intersection-observer
Note: intersection-observer is a polyfill used to support all major browsers
2. Usage Example
In your module:
import { InViewportModule } from 'ng-in-viewport';
import 'intersection-observer';
In your template:
<div in-viewport (inViewportAction)="action($event)" class="circle circle-1">
<i class="onboarding-icon material-icons">local_phone</i>
</div>
In your component:
action(event : any) {
//do something with the element
}
You could for example use Angular's Renderer to add a css class to the element:
import {Renderer2 } from '#angular/core';
...
constructor(private renderer: Renderer2) {}
action(event : any) {
if(event.value){ //if element is in viewport
this.renderer.addClass(event.target, "circle-1");
}
}
I'm trying to build a stepping wizard form layout with a bar at the top of the page containing a dynamic number of steps (nodes) and progress bars connecting the nodes. I'm having trouble getting the progress bars and nodes to cooperate.
The idea is to have each nodes spaced evenly on the page horizontally (already working nicely using flexbox), and the progress bars fluidly filling the gaps between the nodes.
I am currently trying to use an <li> to contain each iteration of the progress bar & <a> pairs, but it is not laying out like I need it to (the progress bars are not behaving fluidly and not filling empty space between the <a> tags).
Is this the best way to lay this out?
Just though I'd confirm this is the best way to lay these out before going any further.
EDIT 1 (Clarifying goal):
This image is an example of what I am trying to achieve.
The progress bar and red <a> node are both within the same <li>. I have given the progress bar a width of 90% for this example but the goal is to only assign a width to the red <a> node and have the project bar fluidly fill the remaining space.
Below is the HTML & SCSS I am currently using:
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">Project Milestones</div>
</div>
<div class="panel-body">
<ul class="milestone-bar">
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 1
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 3
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
50%
</div>
</div>
Milestone 2
</li>
</ul>
</div>
</div>
ul.milestone-bar {
padding: 0;
margin: 0 0 15px 0;
display: flex;
li {
width: 100%;
list-style: none;
display: inline-block;;
a {
width: 30px;
height: 30px;
font-size: 12px;
border-radius: 15px;
background-color: red;
float:right;
&:hover {
background: none;
border: 4px solid blue;
}
&:active {
background-color: darkblue;
}
&:focus {
background-color: green;
}
}
.project-progress {
background-color: #d3d3d3;
display: inline-block;
margin: 0;
}
}
}
Is this on the right track?
Below is a snippet of the above:
ul.milestone-bar {
padding: 0;
margin: 0 0 15px 0;
display: flex;
}
ul.milestone-bar li {
width: 100%;
list-style: none;
display: inline-block;
}
ul.milestone-bar li a {
width: 30px;
height: 30px;
font-size: 12px;
border-radius: 15px;
background-color: red;
float: right;
}
ul.milestone-bar li a:hover {
background: none;
border: 4px solid blue;
}
ul.milestone-bar li a:active {
background-color: darkblue;
}
ul.milestone-bar li a:focus {
background-color: green;
}
ul.milestone-bar li .project-progress {
background-color: #d3d3d3;
display: inline-block;
margin: 0;
}
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">Project Milestones</div>
</div>
<div class="panel-body">
<ul class="milestone-bar">
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 1
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 3
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
50%
</div>
</div>
Milestone 2
</li>
</ul>
</div>
</div>
So I did some changes to your code:
Added flex to each li to create nested flex children here:
ul.milestone-bar li {
width: 100%;
list-style: none;
display: flex;
}
Added flex: 1 for it to flex to the whole width and vertically align it to the center using align-self: center to your project-progress like this:
ul.milestone-bar li .project-progress {
background-color: #d3d3d3;
display: inline-block;
margin: 0;
flex: 1;
align-self: center
}
Added the progress bar style:
ul.milestone-bar li .project-progress .progress-bar {
background: #0095FF;
text-align: center;
}
Also adjusted the milestone-bar to look better:
ul.milestone-bar li a {
width: 60px;
height: 60px;
font-size: 10px;
border-radius: 50%;
background-color: red;
text-align: center;
line-height: 60px;
}
ul.milestone-bar li a:hover {
background: none;
border: 4px solid blue;
line-height: 52px;
}
To top it up, used box-sizing: border-box to all elements in the page for better management of border especially to remove the 'jumps' when you hover.
* {
box-sizing: border-box;
}
ul.milestone-bar {
padding: 0;
margin: 0 0 15px 0;
display: flex;
}
ul.milestone-bar li {
width: 100%;
list-style: none;
display: flex;
}
ul.milestone-bar li a {
width: 60px;
height: 60px;
font-size: 10px;
border-radius: 50%;
background-color: red;
text-align: center;
line-height: 60px;
}
ul.milestone-bar li a:hover {
background: none;
border: 4px solid blue;
line-height: 52px;
}
ul.milestone-bar li a:active {
background-color: darkblue;
}
ul.milestone-bar li a:focus {
background-color: green;
}
ul.milestone-bar li .project-progress {
background-color: #d3d3d3;
display: inline-block;
margin: 0;
flex: 1;
align-self: center
}
ul.milestone-bar li .project-progress .progress-bar {
background: #0095FF;
text-align: center;
}
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">Project Milestones</div>
</div>
<div class="panel-body">
<ul class="milestone-bar">
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 1
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
100%
</div>
</div>
Milestone 3
</li>
<li>
<div class="progress project-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
50%
</div>
</div>
Milestone 2
</li>
</ul>
</div>
</div>
Let me know your feedback on this. Thanks!