I am currently using HTML, CSS, and Bootstrap to design some tabs. Here is the current result I am achieving:
https://i.sstatic.net/qbUck.png
When clicking anywhere on the screen, I see the original results based on my code.
The outcome after clicking anywhere on the screen
How can I address these two issues:
Upon selecting/clicking any tab, I want the text color of the tab to change to red. I have already attempted using the "active" keyword as evident in my code.
The actual result should be displayed immediately, without requiring a click anywhere on the screen.
Here's my code:
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="tab" role="tabpanel">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#medicalNotes" aria-controls="home" role="tab" data-toggle="tab">Medical Notes</a></li>
<li role="presentation" ><a href="#medication" aria-controls="profile" role="tab" data-toggle="tab">Medications</a></li>
<li role="presentation"><a href="#allergies" aria-controls="messages" role="tab" data-toggle="tab">Allergies</a></li>
<li role="presentation"><a href="#vitalsh" aria-controls="messages" role="tab" data-toggle="tab">Vital Social History</a></li>
<li role="presentation"><a href="#familyhh" aria-controls="messages" role="tab" data-toggle="tab">Family Health History</a></li>
</ul>
<div class="tab-content tabs">
<div role="tabpanel" class="tab-pane fade in active" id="medicalNotes">
<h3>Section 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce semper, magna a ultricies volutpat, mi eros viverra massa, vitae consequat nisi justo in tortor. Proin accumsan felis ac felis dapibus, non iaculis mi varius.</p>
</div>
<div role="tabpanel" class="tab-pane fade" id="medication">
<h3>Section 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce semper, magna a ultricies volutpat, mi eros viverra massa, vitae consequat nisi justo in tortor. Proin accumsan felis ac felis dapibus, non iaculis mi varius.</p>
</div>
<div role="tabpanel" class="tab-pane fade" id="allergies">
<h3>Section 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce semper, magna a ultricies volutpat, mi eros viverra massa, vitae consequat nisi justo in tortor. Proin accumsan felis ac felis dapibus, non iaculis mi varius.</p>
</div>
<div role="tabpanel" class="tab-pane fade" id="vitalsh">
<h3>Section 4</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce semper, magna a ultricies volutpat, mi eros viverra massa, vitae consequat nisi justo in tortor. Proin accumsan felis ac felis dapibus, non iaculis mi varius.</p>
</div>
<div role="tabpanel" class="tab-pane fade" id="familyhh">
<h3>Section 5</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce semper, magna a ultricies volutpat, mi eros viverra massa, vitae consequat nisi justo in tortor. Proin accumsan felis ac felis dapibus, non iaculis mi varius.</p>
</div>
</div>
</div>
</div>
</div>
CSS
a:hover,a:focus{
text-decoration: none;
outline: none;
}
.tab .nav-tabs{
border: none;
border-bottom: 2px solid #dc697f;
margin: 0;}
.tab .nav-tabs li a{
padding: 10px 20px;
margin: 0 10px -1px 0;
font-size: 13px;
font-weight: 800;
color: #6da1b7;
text-transform: uppercase;
border: 2px solid #e6e5e1;
border-bottom: none;
border-radius: 5px 5px 0 0;
z-index: 1;
position: relative;
transition: all 0.3s ease 0s;
}
.tab .nav-tabs li.active a{
background: #fff;
color: #6da1b7;
border: 2px solid #dc697f;
border-bottom-color: transparent;
border-top-width: 3px;
border-right-width: 1px;
border-left-width: 1px;
border-radius: 7px;
}
.tab .nav-tabs li a:before{
content: "";
display: block;
height: 3px;
background: #fff;
position: absolute;
bottom: -2px;
left: 0;
right: 0;
transform: scaleX(0);
transition: all 0.3s ease-in-out 0s;
}
.nav-tabs > li > a{
color: #D33E1E;
}
.tab .nav-tabs li.active a:before,
.tab .nav-tabs li a:hover:before{ transform: scaleX(1); }
.tab .tab-content{
padding: 10px;
font-size: 19px;
color: #6f6f6f;
line-height: 30px;
letter-spacing: 1px;
position: relative;
}
@media only screen and (max-width: 479px){
.tab .nav-tabs{ border: none; }
.tab .nav-tabs li{
width: 100%;
text-align: center;
margin-bottom: 15px;
}
.tab .nav-tabs li a{
margin: 0;
border-bottom: 2px solid transparent;
}
.tab .nav-tabs li a:before{
content: "";
width: 100%;
height: 2px;
background: #dc697f;
position: absolute;
bottom: -2px;
left: 0;
}
}