![图片[1]-好看的横向水平时间轴 纯 html + css - 易微帮-易微帮](https://yiweibang.com/wp-content/uploads/2022/04/微信截图_20220419100144.png)
![图片[2]-好看的横向水平时间轴 纯 html + css - 易微帮-易微帮](https://yiweibang.com/wp-content/uploads/2022/04/微信截图_20220419100233.png)
<div class="toggle">
<span>☀️</span>
<input type="checkbox" id="toggle-switch" />
<label for="toggle-switch"></label>
<span>🌙</span>
</div>
<div class="main-container">
<div class="steps-container">
<div class="step completed">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" />
</svg>
<div class="label completed">
Sales
</div>
<div class="top completed">
Awaiting Confirmation
</div>
</div>
<div class="line completed"></div>
<div class="step completed">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" />
</svg>
<div class="label completed">
Accountant
</div>
<div class="top completed">
Awaiting Review
</div>
</div>
<div class="line next-step-in-progress">
</div>
<div class="step in-progress">
<div class="preloader"></div>
<div class="label loading">
OP
</div>
<div class="top in-progress">
Stock Check
</div>
</div>
<div class="line prev-step-in-progress"></div>
<div class="step">
<div class="label">
Sales Assistant
</div>
<div class="top">
Preparing Shipping
</div>
</div>
<div class="line"></div>
<div class="step">
<div class="label">
Sales Assistant
</div>
<div class="top">
Awaiting Stock Out
</div>
</div>
<div class="line "></div>
<div class="step">
<div class="label">
Warehouse
</div>
<div class="top">
Stocked Out
</div>
</div>
<div class="line "></div>
<div class="step">
<div class="label">
Warehouse
</div>
<div class="top">
Shipped
</div>
</div>
</div>
</div>
<script type="text/javascript">
const toggleSwitch = document.getElementById('toggle-switch');
toggleSwitch.onchange = e => {
document.documentElement.classList.toggle('dark-mode');
};
</script>
CSS:
<style>
:root {
--background-modal-color: #fff;
--body-color: #fff;
--color-timeline-default: #D2D3D8;
--color-step-completed: #5C6174;
--color-checkmark-completed: #fff;
--color-in-progress: #13CB8F;
--color-label-default: var(--color-timeline-default);
--color-label-completed: var(--color-step-completed);
--color-label-loading: var(--color-in-progress);
--color-icon-completed: var(--color-step-completed);
--color-icon-default: var(--color-timeline-default);
}
:root.dark-mode {
--color-checkmark-completed: #fff;
--background-modal-color: #5C6174;
--color-timeline-default: #9799A3;
--color-checkmark-completed: var(--background-modal-color);
--body-color: #fff;
--color-step-completed: #fff;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Muli', sans-serif;
background: var(--body-color);
padding: 0;
margin: 0;
display: flex;
width: 100vw;
height: 100vh;
justify-content: center;
align-items: center;
position: relative;
}
body .toggle {
transform: scale(0.8);
position: absolute;
bottom: 30px;
display: flex;
align-items: center;
justify-content: space-around;
max-width: 140px;
}
body .toggle span {
margin: 0 0.5rem;
}
body .toggle input[type="checkbox"] {
height: 0;
width: 0;
visibility: hidden;
}
body .toggle input[type="checkbox"]:checked + label {
background: #13CB8F;
}
body .toggle input[type="checkbox"]:checked + label:after {
left: calc(100% - 2px);
transform: translateX(-100%);
}
body .toggle label {
cursor: pointer;
width: 75px;
height: 34px;
background: #D2D3D8;
display: block;
border-radius: 40px;
position: relative;
}
body .toggle label:after {
content: "";
position: absolute;
top: 2px;
left: 2px;
width: 30px;
height: 30px;
background: #fff;
border-radius: 40px;
transition: 0.3s;
}
body .main-container {
display: flex;
flex-direction: column;
justify-content: center;
transition: all 200ms ease;
background: var(--background-modal-color);
height: 220px;
min-width: 420px;
max-width: 100%;
flex-grow: 1;
border-radius: 5px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.14);
}
body .main-container .steps-container {
padding: 40px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
body .main-container .steps-container .step {
z-index: 1;
position: relative;
display: flex;
align-items: center;
justify-content: center;
transition: all 200ms ease;
flex-grow: 0;
height: 15px;
width: 15px;
border: 4px solid var(--color-timeline-default);
border-radius: 50%;
}
body .main-container .steps-container .step .preloader, body .main-container .steps-container .step svg {
display: none;
}
body .main-container .steps-container .step.completed {
width: 18px;
height: 18px;
background: var(--color-step-completed);
border: none;
}
body .main-container .steps-container .step.completed svg {
transition: all 200ms ease;
display: block;
height: 10px;
width: 10px;
fill: var(--color-checkmark-completed);
}
body .main-container .steps-container .step.in-progress {
width: 18px;
height: 18px;
background: var(--color-in-progress);
border: none;
}
body .main-container .steps-container .step.in-progress .preloader {
display: block;
height: 10px;
width: 10px;
border: 2px solid #fff;
border-radius: 50%;
border-left-color: transparent;
animation-name: spin;
animation-duration: 2000ms;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
body .main-container .steps-container .step .label {
position: absolute;
top: 30px;
filter: none;
z-index: 2000;
color: var(--color-label-default);
transition: all 200ms ease;
font-weight: 700;
}
body .main-container .steps-container .step .label.completed {
color: var(--color-label-completed);
}
body .main-container .steps-container .step .label.loading {
color: var(--color-label-loading);
}
body .main-container .steps-container .step .top {
font-size: 16px;
position: absolute;
top: -60px;
color: var(--color-icon-default);
transition: color 200ms ease;
}
body .main-container .steps-container .step .top.completed {
color: var(--color-icon-completed);
}
body .main-container .steps-container .step .top.in-progress {
color: var(--color-in-progress);
}
body .main-container .steps-container .line {
transition: all 200ms ease;
height: 2px;
flex-grow: 1;
max-width: 120px;
background: var(--color-timeline-default);
}
body .main-container .steps-container .line.completed {
background: var(--color-step-completed);
}
body .main-container .steps-container .line.next-step-uncomplete {
background: linear-gradient(to right, var(--color-step-completed), var(--color-timeline-default));
}
body .main-container .steps-container .line.next-step-in-progress {
background: linear-gradient(to right, var(--color-step-completed), var(--color-in-progress));
}
body .main-container .steps-container .line.prev-step-in-progress {
background: linear-gradient(to right, var(--color-in-progress), var(--color-timeline-default));
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
试一下效果便知,上下都是文字当然也可以修改为图标。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧
请登录后发表评论
注册
社交帐号登录