css+js实现垂直滚动tab选项卡效果代码

代码语言:html

所属分类:选项卡

代码描述:css+js实现垂直滚动tab选项卡效果代码

代码标签: css js 垂直 滚动 tab 选项卡

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
  
        <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'
        >
<style>
    

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

body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 1rem;
    background-color: var(--body-background);
}

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

.tabs-container {
	padding: 1rem;
    width: 100%;
    max-width: 30rem;
    min-width: 20rem;
    display: flex;
	margin: 0.75rem;
	border-radius: 1rem;
    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: 18.75rem;
    transition: all 0.45s ease-in-out;
    padding: 0 1rem;
}

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

.tab-content {
    font-size: 0.8rem;
    min-height: 18.75rem;
    min-width: 15rem;
    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: 1rem;
    gap: 0.5rem;
}

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

.tabs a img {
    height: 1.25rem;
    width: 1.25rem;
}

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

.tabs a svg {
    stroke: var(--gray-mid);
}

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

.tabs a:hover svg {
    stroke: var(--white);
}
</style>
    </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=&q.........完整代码请登录后点击上方下载按钮下载查看

网友评论0