I have 2 collapsing tabs which each display 5 progress bars on each tab. I would like for the progress bar percentage eg '79%', to change to show grade eg 'B+' when a user hovers over the bar. How can I achieve this?
2nd question: I want to make each tab collapse the other tab eg when I select 'Semester 1' I want 'Semester 2' to be hidden and vise versa. If I close 'Semester 1' I want 'Semester 2' to show etc.
https://jsfiddle.net/oed6vbt9/
code
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<section id="education" style="background-color:whitesmoke;">
<div class="container">
<div class="row d-flex no-gutters">
<div class="col-lg-12 mx-auto">
<h2 style="text-align: center;"> Education </h2>
<br>
<br>
<br>
<div class="pull-left" style="color: rgba(0, 0, 0, 0.801);">
<h3>BSc in Computing</h3>
<br>
</div>
<div class="row">
<br>
<br>
<div class="col-md-4 disabled">
<div class="tu-icon">
<a target="_blank" href="https://www.it-tallaght.ie/">
<img class="mx-auto mb-2" src="tudub.png" alt="about"
style="width: 100%; height: 100%; border:2px solid #000000">
</a>
</div>
</div>
<div class="col-md-8">
<!--nav tabs-->
<div class="tabs">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#first" data-toggle="tab"> First Year </a>
</li>
<li role="presentation">
<a href="#second" data-toggle="tab"> Second Year </a>
</li>
</ul>
</div>
<!--Start single tab content-->
<div class="tab-content">
<div class="service-box tab-pane fade in active row show" id="first">
<div class="contents">
<div class="section-title">
<br>
<h4 style="color: rgba(0, 0, 0, 0.801);"> First Year</h4>
<br>
</div>
<div class="col-md-8 animate-box">
<div class="panel-group" id="accordion">
<!--Collapse Semester 1-->
<div class="panel panel-default show">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">Semester 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in show">
<div class="panel-body">
<!--progress bars-->
<h5>Software Development B+</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="79"
aria-valuemin="0" aria-valuemax="100" style="width:79%">
<span>79%</span>
</div>
</div>
<br>
<h5>Business Information Systems B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="69"
aria-valuemin="0" aria-valuemax="100" style="width:69%">
<span>69%</span>
</div>
</div>
<br>
<h5>Visual Design B-</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="59"
aria-valuemin="0" aria-valuemax="100" style="width:59%">
<span>59%</span>
</div>
</div>
<br>
<h5>Systems Analysis B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="69"
aria-valuemin="0" aria-valuemax="100" style="width:69%">
<span>69%</span>
</div>
</div>
<br>
<h5>Statistics B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="69"
aria-valuemin="0" aria-valuemax="100" style="width:69%">
<span>69%</span>
</div>
</div>
<br>
</div>
</div>
</div>
<!--Collapse Semester 2-->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse2">Semester 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
<!--progress bars-->
<h5>Software Development 2 B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="68"
aria-valuemin="0" aria-valuemax="100" style="width:68%">
<span>68%</span>
</div>
</div>
<br>
<h5>Introduction to Operating Systems B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="69"
aria-valuemin="0" aria-valuemax="100" style="width:69%">
<span>69%</span>
</div>
</div>
<br>
<h5>Web and Datasbase Fundementals B-</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="59"
aria-valuemin="0" aria-valuemax="100" style="width:59%">
<span>59%</span>
</div>
</div>
<br>
<h5>Discrete Mathematics B-</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="59"
aria-valuemin="0" aria-valuemax="100" style="width:59%">
<span>59%</span>
</div>
</div>
<br>
<h5>Systems Analysis 2 B</h5>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="69"
aria-valuemin="0" aria-valuemax="100" style="width:69%">
<span>69%</span>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--End single tab content-->
<!--Start single tab content-->
<div class="service-box tab-pane fade in" id="second">
<div class="contents">
<div class="section-title">
<br>
<h3> Second Year</h3>
<br>
</div>
<div class="col-md-8 animate-box">
<div class="progress-wrap">
<h3>Java</h3>
<div class="progress" style="width: 100%;">
<div class="progress-bar color-1" role="progressbar" aria-valuenow="90" aria-valuemin="0"
aria-valuemax="100" style="width:90%">
<span>90%</span>
</div>
</div>
</div>
<br>
<div class="progress-wrap ftco-animate">
<h3>C#</h3>
<div class="progress">
<div class="progress-bar color-2" role="progressbar" aria-valuenow="85" aria-valuemin="0"
aria-valuemax="100" style="width:85%">
<span>85%</span>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
<!--End single tab content-->
</div>
</div>
</div>
</div>
</div>
</div>
</section>
css:
section {
padding: 150px 0;
}
header {
padding: 156px 0 100px;
}
.it-icons a {
display: inline-block;
height: 3.5rem;
width: 3.5rem;
background-color: #4582EC;
color: #fff !important;
border-radius: 100%;
text-align: center;
font-size: 1.5rem;
line-height: 3.5rem;
margin-right: 1rem;
}
.it-icons a:hover {
transform: scale(1.3) rotate(20deg);
background-color: skyblue;
}
.tu-icon a:hover {
transform: rotate(5deg);
}
.os-icons a {
display: inline-block;
height: 3.5rem;
width: 3.5rem;
background-color: #4582EC;
color: #fff !important;
border-radius: 100%;
text-align: center;
font-size: 1.5rem;
line-height: 3.5rem;
margin-right: 1rem;
}
.os-icons a:hover {
transform: scale(1.3) rotate(20deg);
background-color: skyblue;
}
.tabs .nav-tabs > li, .tabs .nav-pills > li {
float: none;
display: inline-block;
margin-bottom: 10px;
padding: 5px 5px;
}
.tabs .nav-tabs {
text-align: center;
border-bottom: 0;
margin-bottom: 20px;
}
.tabs .nav-tabs li:not(:last-child) {
margin-right: 10px;
}
.tabs .nav-tabs li a {
text-transform: capitalize;
font-size: 20px;
padding: 10px 25px;
border: 2px solid #4582EC;
border-radius: 0;
transition: all .3s ease;
font-weight: 600;
color: #4582EC;
font-family: "Source Sans Pro", sans-serif;
}
.tabs .nav-tabs li a:hover {
background: #4582EC;
color: #fff;
border: 2px solid #4582EC;
}
.tabs .nav-tabs li.active a {
color: #fff;
background: #4582EC;
border: 2px solid #4582EC;
}
.service-box {
position: relative;
width: 100%;
}
.service-box .contents {
margin-left: 30px;
}
.tab-content {
position: relative;
float: left;
width: 100%;
z-index: 99;
}
.service-box {
position: relative;
width: 100%;
}
.service-box .section-title h3 {
position: relative;
font-size: 32px;
line-height: 42px;
font-weight: 700;
padding-bottom: 20px;
margin-bottom: 45px;
color: #000;
text-transform: uppercase;
}
.service-box .section-title h3:before {
position: absolute;
left: 0px;
content: '';
bottom: 0px;
background: #333333;
height: 1px;
width: 55px;
}
Add 2 elements inside .progress-bar
, one for percentage and one for grade. Then hide one by default. Then toggle visibility based on parent hover.
.progress .progress-bar > span { position:relative; height:100%; } .progress .progress-bar > span > * { position:absolute; top:0; transition: opacity .3s ease-out; } .progress .grade { opacity:0; } .progress:hover .grade { opacity:1; } .progress:hover .percentage { opacity:0; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <div class="progress" style="width: 100%;"> <div class="progress-bar color-1" role="progressbar" aria-valuenow="79" aria-valuemin="0" aria-valuemax="100" style="width:79%"> <span><span class="percentage">79%</span><span class="grade">B+</span></span> </div> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.