Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Tabs</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="preconnect" href="https://fonts.googleapis.com">
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link
            href="https://fonts.googleapis.com/css2?family=Poppins&display=swap"
            rel="stylesheet"
            type='text/css'
        >
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <div class="tabs-container">
            <ul class="tabs">
                <li>
                    <a id="tab1" title="Analytics" href="#tab1">
                        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24"
                             viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" 
                             fill="none" stroke-linecap="round" stroke-linejoin="round"
                        >
                            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                          <path d="M3 3v18h18"></path>
                            <path d="M20 18v3"></path>
                            <path d="M16 16v5"></path>
                            <path d="M12 13v8"></path>
                            <path d="M8 16v5"></path>
                            <path d="M3 11c6 0 5 -5 9 -5s3 5 9 5"></path>
                        </svg>
                        Analytics
                    </a>
                </li>
                <li>
                    <a id="tab2" title="Reports" href="#tab2">
                        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" 
                             viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                             fill="none" stroke-linecap="round" stroke-linejoin="round"
                        >
                            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                            <path d="M7 7m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0"></path>
                            <path d="M7 3v4h4"></path>
                            <path d="M9 17l0 4"></path>
                            <path d="M17 14l0 7"></path>
                            <path d="M13 13l0 8"></path>
                            <path d="M21 12l0 9"></path>
                        </svg>
                        Reports
                    </a>
                </li>

                <li>
                    <a id="tab3" title="Performance" href="#tab3">
                        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24"
                             height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                             fill="none" stroke-linecap="round" stroke-linejoin="round"
                        >
                            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                            <path d="M3 12m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"></path>
                            <path d="M9 8m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"></path>
                            <path d="M15 4m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v14a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"></path>
                            <path d="M4 20l14 0"></path>
                        </svg>
                        Performance
                    </a>
                </li>
                <li>
                    <a id="tab4" title="Funds" href="#tab4">
                        <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24"
                             height="24" viewBox="0 0 24 24" stroke-width="2" 
                             stroke="currentColor" fill="none" stroke-linecap="round" 
                             stroke-linejoin="round"
                        >
                            <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                            <path d="M3 21l18 0"></path>
                            <path d="M3 10l18 0"></path>
                            <path d="M5 6l7 -3l7 3"></path>
                            <path d="M4 10l0 11"></path>
                            <path d="M20 10l0 11"></path>
                            <path d="M8 14l0 3"></path>
                            <path d="M12 14l0 3"></path>
                            <path d="M16 14l0 3"></path>
                        </svg>               
                        Funds
                    </a>
                </li>
            </ul>
            <div class="tab-content-wrapper">
                <section id="tab1-content" class="tab-content">
                    <h2>Analytics</h2>
                    <p>
                        Investment analytics involves the use of data, statistical techniques, and financial models to evaluate and optimize investment decisions. It's a discipline that aids investors in understanding potential risks and returns associated with various investment choices. Investment analytics can range from basic data analysis to complex quantitative models and can be applied to various asset classes.
                    </p>
                </section>
                <section id="tab2-content" class="tab-content">
                    <h2>Reports</h2>
                    <p>
                        Investment reports provide detailed information about the status, performance, and other relevant aspects of an investment or portfolio. They can be generated for individual investors or institutional investors and are typically used to assess the health, progress, and potential future trajectory of investments.
                    </p> 
                </section> 
                <section id="tab3-content" class="tab-content">
                    <h2>Performance</h2>
                    <p>
                        Investment performance refers to the returns generated on an investment relative to the amount of money invested. It's a way to measure and evaluate the growth or decline of an investment over a specific period, often compared to benchmarks or other standards to determine its relative success.
                    </p>
                </section>
                <section id="tab4-content" class="tab-content">
                    <h2>Funds</h2>
                    <p>
                        Investment funds are pooled collections of money from multiple investors that are managed collectively by professionals or on behalf of the investors. The main objective of these funds is to provide both individual and institutional investors access to a wider range of securities than they might be able to access individually. By doing so, they can achieve diversification, professional management, and economies of scale in investment.
                    </p>
                </section>
            </div>
        </div>
        <script src="script.js"></script>
    </body>
</html>
    
              
            
!

CSS

              
                :root {
    --white: #FFF;
  --black
    --gray: #F3F3F3;
    --gray-mid: #9D9D9D;
    --gray-dark: #3e3e3e;
    --gray-hover: #F7F7F7;
    --body-background: grey;
}

body {
    font-family: 'Poppins';
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 16px;
    background-color: var(--body-background);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.tabs-container {
	padding: 16px;
    width: 100%;
    max-width: 480px;
    min-width: 320px;
    display: flex;
	margin: 10px;
	border-radius: 16px;
    background-color: var(--white);
	box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;	
}

header {
    position: relative;
}

.tab-content-wrapper {
    overflow-y: hidden;
    overflow-x: auto;
    height: 300px;
    transition: all 0.45s ease-in-out;
    padding: 0 16px;
}

.tab-content h2 {
    color: var(--gray-dark);
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 0px;
    margin-bottom: 8px;
}

.tab-content {
    font-size: 0.8rem;
    min-height: 300px;
    min-width: 240px;
    overflow-x: auto;
    transition: all 0.45s ease-in-out;
}

.tabs {
    position: relative;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #F0F0F0;
    list-style-type: none;
    padding-right: 16px;
    gap: 8px;
}

.tabs a {
    position: relative;
    display: flex;
    text-decoration: none;
    width: 100%;
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
    text-align: left;
    border-radius: 8px;
    justify-content: start;
    padding: 12px;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease-in-out;
}

.tabs a img {
    height: 20px;
    width: 20px;
}

.tabs .active, .tabs a:hover {
    font-weight: 700;
    outline: none;
    color: white;
    background-color: var(--gray-dark);
}


.tabs a svg {
    stroke: var(--black;
}

.tabs .active svg {
    stroke: var(--black);
}

.tabs a:hover svg {
    stroke: var(--black);
}
              
            
!

JS

              
                const allLinks = document.querySelectorAll(".tabs a");
const allTabs = document.querySelectorAll(".tab-content")
const tabContentWrapper = document.querySelector(".tab-content-wrapper");

const shiftTabs = (linkId) => {
  allTabs.forEach((tab, i) => {
      
    if (tab.id.includes(linkId)) {
      allTabs.forEach((tabItem) => { 
        tabItem.style = `transform: translateY(-${i*300}px);`;
      });
    }
  });
}

allLinks.forEach((elem) => {
  elem.addEventListener('click', function() {
    const linkId = elem.id;
    const hrefLinkClick = elem.href;

    allLinks.forEach((link, i) => {
      if (link.href == hrefLinkClick){
        link.classList.add("active");
      } else {
        link.classList.remove('active');
      }
    });

    shiftTabs(linkId);
  });
});

//? handle proper selection for initial load
const currentHash = window.location.hash;

let activeLink = document.querySelector(`.tabs a`);

if (currentHash) {
  const visibleHash = document.getElementById(
    `${currentHash.replace('#', '')}`
  );

  if (visibleHash) {
    activeLink = visibleHash;
  }
}

activeLink.classList.toggle('active');

shiftTabs(activeLink.id);
              
            
!
999px

Console