HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
: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);
}
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);
Also see: Tab Triggers