Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<div class="tab-contnet">    
<div class="btn-group checkout-btn" role="group" id="tabs">
     <a href="#" class="btn active" id =>電子發票</a>
    <a href="#" class="btn" id =>郵寄發票</a>
                    </div>
                    <!-- form 電子發票 -->
  <div id="tab-inner" class="">
                    <form class="form-content" id =tab1>
                        <div class="form-group">
                            <label for="email">電子郵件信箱</label>
                            <input type="email" class="form-control" id="email" placeholder="example@email.com">
                        </div>
                        <div class="form-group">
                            <label for="num">統一編號(選填)</label>
                            <input type="number" class="form-control" id="num" placeholder="12345678">
                        </div>
                    </form>

   <!-- form 郵寄發票 -->
                    <form class="form-content">
                        <div class="form-row">
                            <div class="form-group">
                                <label for="city">地址</label>
                                <select id="city" class="form-control">
                                    <option selected>高雄市</option>
                                    <option>台北市</option>
                                </select>
                            </div>
        <div class="form-group  d-flex flex-column justify-content-end">
                <div class="form-group form-check mb-1 text-right">
                   <input type="checkbox" class="form-check-input" id="exampleCheck1">
                   <label class="form-check-label text-size-sm" for="exampleCheck1">同運送地址</label>
                                </div>
                                <select id="dist" class="form-control">
                                    <option selected>新興區</option>
                                    <option>三民區</option>
                                </select>
                            </div>
          <div class="form-group ">
          <input type="text" class="form-control" placeholder="幸福路 520號">
                            </div>
                        </div>
             <div class="form-group">
                            <label for="num">統一編號(選填)</label>
                            <input type="number" class="form-control" id="num" placeholder="12345678">
                        </div>
                    </form>
    </div>
</div> 
              
            
!

CSS

              
                
  *, ::after, ::before {
    box-sizing: border-box;
}

a{
  text-decoration: none;
}

.tab-contnet{
  display:flex;
  flex-direction:column;
  margin:20px auto;
  max-width: 460px;
  //   height: 580px;
    background-color: #3F5D45;
    margin-bottom: 20px;
    padding: 30px 40px;
    position: relative;
  
}

.form-group{
  color:#fff;
      margin-bottom: 1rem;
  label{
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 20px;
    font-weight: bold;
  }
  .form-control{
    display: block;
    width: 100%;
    -webkit-appearance: none;
    background-color: #EAF0ED;
    height: auto;
    border: none;
    padding: 17px 20px;
    color: #8DA291;
        font-size: 1rem;
    line-height: 1.5;
  }
}
.btn-group{

  position: relative;
    display: inline-flex;
    // vertical-align: middle;
    justify-content: center;
  align-items:center;
}

.checkout-btn {
    width: 100%;
    margin-bottom: 30px;
  .btn{
        width: 50%;
    line-height: 56px;
    padding: 0;
    font-size: 20px;
    background-color: #3F5D45;
    border-radius: 0;
    color: #EAF0ED;
    text-align:center;
    font-weight: bold;
    border: 1px solid #EAF0ED;
    &.active{
          background-color: #EAF0ED;
    color: #3F5D45;
    }
  }
}
              
            
!

JS

              
                let tabLink = document.getElementById("tabs").querySelectorAll("a");

let tabContents = document.getElementById("tab-inner").querySelectorAll('.form-content');

window.onload = function (){

    // 啟動第一個panel
     panelDisplay(tabLink[0]);
     //點擊  tab a連結
     for(let i = 0; i < tabLink.length; i++){
       tabLink[i].addEventListener('click',function(e){
        e.preventDefault();
         panelDisplay(this);
         // return false;
       });
       
       };
   
       function panelDisplay(activePanel){
          // Do something...
          for(let i =0;i<tabLink.length;i++){
                
            //設定條件tabLink ==activePanel 
            //將tablink代入for循環中並利用 if ...else 進行條件 classList.add增加class="active" ,就是每執行一次function的時候就進行全部tablinks增加class
           
              if(tabLink[i] == activePanel){
                tabLink[i].classList.add("active");
                tabContents[i].style.display="block";
                
              }else{
                tabLink[i].classList.remove("active");
                tabContents[i].style.display="none";
              }
          }
       }
  
     };
   
   



              
            
!
999px

Console