gpt4 book ai didi

javascript - 悬停时更改进度条跨度文本

转载 作者:行者123 更新时间:2023-11-28 16:50:24 27 4
gpt4 key购买 nike

我有 2 个折叠选项卡,每个选项卡上显示 5 个进度条。我想要进度条百分比,例如'79%',更改为显示等级,例如当用户将鼠标悬停在栏上时为“B+”。我怎样才能做到这一点?

第二个问题:我想让每个选项卡折叠另一个选项卡,例如当我选择“第一学期”时,我希望隐藏“第二学期”,反之亦然。如果我关闭“第 1 学期”,我希望显示“第 2 学期”等。

https://jsfiddle.net/oed6vbt9/

代码

<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;
}

最佳答案

.progress-bar 中添加 2 个元素,一个用于百分比,一个用于等级。然后默认隐藏一个。然后根据父悬停切换可见性。

.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>

关于javascript - 悬停时更改进度条跨度文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59184253/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com