Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141188

tabs between content divs, first div not activating on load

$
0
0

I have 2 divs which I need to navigate between using 2 navigation tabs: Year 1 and Year 2. The navigation works fine when I click on Year 1, "first" div appears, and the same for div "second". My problem is that when the page is first loaded, neither div is active. How do I make it so "first" div is always showing when page is first loaded? I have looked through a number of posts but still can not fix this

i.e. when page is first loaded neither tab is showing until I click on them

enter image description here

It should look like this on page load:

enter image description here

Current code:

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

          <div class="row">
            <br>
            <br>

            <div class="col-md-8">

              <!--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" id="first">
                  <div class="contents">

                    <div class="section-title">
                      <br>
                      <h3> First Year</h3>
                      <br>
                    </div>

                   <div class="col-md-8 animate-box">
                      <div class="progress-wrap">
                        <h3>Photoshop</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>jQuery</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-->
                <!--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;
}

Viewing all articles
Browse latest Browse all 141188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>