I want to keep first tab open for multiple horizontal tabs.

shilpa647 0 Tallied Votes 207 Views Share

After page loading , when I click on the ellipsis , horizontal tabs transform from bottom of the product image . After opening of the tabs menu bar , first tab should open by default.I tried multiple solutions but none of them worked out.

<div class="row">
    <div class="product card">
      <div class="wrapper">
        <img src="images/boxer.jpg" alt="Boxer image" width="300px" height="400px">
        <div class="data">
            <div class="content">
                   <label for="show-menu" class="menu-button"><span></span></label>
            </div>
                 <input type="checkbox" id="show-menu" />
 
                 <div id="tabs"  class="menu-content">
                       <button class="tablink" onclick="openCity('Details', this, 'orange')" id="defaultOpen">Details</button>
                       <button class="tablink" onclick="openCity('Ratings', this, 'orange')">Ratings</button>
                       <button class="tablink" onclick="openCity('Cart', this, 'orange')">Cart</button>
                       <button class="tablink" onclick="openCity('Content', this, 'orange')">Content</button>


                             <div id="Details" class="tabcontent">
                              <h1>London</h1>
                               <p>London is the capital city of England.</p>
                             </div>

                             <div id="Ratings" class="tabcontent">
                                <h1>Paris</h1>
                                     <p>Paris is the capital of France.</p> 
                             </div>

                            <div id="Cart" class="tabcontent">
                                <h1>Tokyo</h1>
                              <p>Tokyo is the capital of Japan.</p>
                           </div>

                           <div id="Content" class="tabcontent">
                                 <h1>Oslo</h1>
                                 <p>Oslo is the capital of Norway.</p>
                           </div>
            </div>

   

        </div>
      </div>
    </div>

<script type="text/javascript">
    //document.getElementsByClassName('tablinks')[0].click();
    window.onload = function () {
      startTab();
   };
   function startTab() {
    document.getElementById("defaultOpen").click();

  }

  function openCity(cityName,elmnt,color) {
    let i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablink");
    for (i = 0; i < tablinks.length; i++) {
      tablinks[i].style.backgroundColor = "";
      
    }
    document.getElementById(cityName).style.display = "block";
    elmnt.style.backgroundColor = color;
    //elmnt.currentTarget.className += " active";
  
  }
  </script>
  
  <!--- css part ---->
  
  * {
  box-sizing: border-box;
}


a {
  text-decoration: none;
}

h1 {
  font-family: "Open Sans", sans-serif;
  font-weight: 300;
}

.row {
  max-width: 900px;
  margin: 50px auto 0;
}

.card {
  float: left;
  padding: 0 1.7rem;
}
.card .menu-content {
  margin: 0;
  padding: 0;
  list-style-type: none;
}
.card .menu-content::before, .card .menu-content::after {
  content: "";
  display: table;
}
.card .menu-content::after {
  clear: both;
}
.card .menu-content li {
  display: inline-block;
}
.card .menu-content a {
  color: #fff;
}
.card .menu-content span {
  position: absolute;
  left: 50%;
  top: 0;
  font-size: 10px;
  font-weight: 700;
  font-family: "Open Sans";
  transform: translate(-50%, 0);
}
.card .wrapper {
  background-color: #fff;
  min-height: 400px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.2);
}
.card .wrapper:hover .data {
  transform: translateY(0px);
}
.card .data {
  position: absolute;
  bottom: 0;
  width: 100%;
 /* transform: translateY(calc(70px + 1em));*/
  transition: transform 0.3s;
}
.card .data .content {
  padding: 1em;
  position: relative;
  z-index: 1;
  float:right;
  margin-bottom:133px;
  border-radius:5px;
  cursor:pointer;
}
.card .author {
  font-size: 12px;
}
.card .title {
  margin-top: 10px;
}
.card .text {
  height: 70px;
  margin: 0;
}
.card input[type=checkbox] {
  display: none;
}
.card input[type=checkbox]:checked + .menu-content {
  transform: translateY(-60px);
}



.product .content {
  background-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 5px 30px 10px rgba(0, 0, 0, 0.3);
  height:50px;
  width:56px;
  /*border-radius:50%;*/
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  /*float:right;*/

}
.product .title a {
  color: gray;
}
.product .menu-button {
  position: absolute;
  z-index: 999;
  top: 10px;
  right: 16px;
  width: 25px;
  text-align: center;
  cursor: pointer;
}
.product .menu-button span {
  width: 5px;
  height: 5px;
  background-color:black;
  color:black;
  position: relative;
  display: inline-block;
  border-radius: 50%;
}
.product .menu-button span::after, .product .menu-button span::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  background-color: currentColor;
  position: absolute;
  border-radius: 50%;
}
.product .menu-button span::before {
  left: -10px;
}
.product .menu-button span::after {
  right: -10px;
}
.product .menu-content {
  text-align: center;
  position: absolute;
  top: 110px;
  left: 0;
  width: 100%;
  z-index: -1;
  transition: transform 0.3s;
  transform: translateY(90px);
}
/*.product .menu-content li {
  width: 100%;
  float: left;
  background-color: #77d7b9;
  height: 48px;
  position: relative;
}

.product .menu-content a {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
}

.product .menu-content span {
  top: -10px;
}
*/

.tab-content {
  overflow: hidden !important;
}


.tablink{
  background-color: #555;
  color: white;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 10px;
  font-size: 13px;
  width: 25%;

}


.tabcontent {
  color: white;
  display: none;
  padding: 10px;
  width:270px;
  text-align: center;
  background-color:gray;
  display:flex;
  
}