css div自定义属性,一款使用CSS自定义属性实现的时间轴布局

CSS

语言:

CSSSCSS

确定

.timeline {

--uiTimelineMainColor: var(--timelineMainColor, #222);

--uiTimelineSecondaryColor: var(--timelineSecondaryColor, #fff);

position: relative;

padding-top: 3rem;

padding-bottom: 3rem;

}

.timeline:before {

content: "";

width: 4px;

height: 100%;

background-color: var(--uiTimelineMainColor);

position: absolute;

top: 0;

}

.timeline__group {

position: relative;

}

.timeline__group:not(:first-of-type) {

margin-top: 4rem;

}

.timeline__year {

padding: .5rem 1.5rem;

color: var(--uiTimelineSecondaryColor);

background-color: var(--uiTimelineMainColor);

position: absolute;

left: 0;

top: 0;

}

.timeline__box {

position: relative;

}

.timeline__box:not(:last-of-type) {

margin-bottom: 30px;

}

.timeline__box:before {

content: "";

width: 100%;

height: 2px;

background-color: var(--uiTimelineMainColor);

position: absolute;

left: 0;

z-index: -1;

}

.timeline__date {

min-width: 65px;

position: absolute;

left: 0;

box-sizing: border-box;

padding: .5rem 1.5rem;

text-align: center;

background-color: var(--uiTimelineMainColor);

color: var(--uiTimelineSecondaryColor);

}

.timeline__day {

font-size: 2rem;

font-weight: 700;

display: block;

}

.timeline__month {

display: block;

font-size: .8em;

text-transform: uppercase;

}

.timeline__post {

padding: 1.5rem 2rem;

border-radius: 2px;

border-left: 3px solid var(--uiTimelineMainColor);

box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 1px 2px 0 rgba(0, 0, 0, .24);

background-color: var(--uiTimelineSecondaryColor);

}

@media screen and (min-width: 641px) {

.timeline:before {

left: 30px;

}

.timeline__group {

padding-top: 55px;

}

.timeline__box {

padding-left: 80px;

}

.timeline__box:before {

top: 50%;

-webkit-transform: translateY(-50%);

transform: translateY(-50%);

}

.timeline__date {

top: 50%;

margin-top: -27px;

}

}

@media screen and (max-width: 640px) {

.timeline:before {

left: 0;

}

.timeline__group {

padding-top: 40px;

}

.timeline__box {

padding-left: 20px;

padding-top: 70px;

}

.timeline__box:before {

top: 90px;

}

.timeline__date {

top: 0;

}

}

.timeline {

--timelineMainColor: #4557bb;

font-size: 16px;

}

@media screen and (min-width: 768px) {

html {

font-size: 62.5%;

}

}

@media screen and (max-width: 767px) {

html {

font-size: 55%;

}

}

/*

* demo page

*/

@media screen and (min-width: 768px) {

html {

font-size: 62.5%;

}

}

@media screen and (max-width: 767px) {

html {

font-size: 50%;

}

}

body {

font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Open Sans, Ubuntu, Fira Sans, Helvetica Neue, sans-serif;

font-size: 1.6rem;

color: #222;

background-color: #f0f0f0;

margin: 0;

-webkit-overflow-scrolling: touch;

overflow-y: scroll;

}

p {

margin-top: 0;

margin-bottom: 1.5rem;

line-height: 1.5;

}

p:last-child {

margin-bottom: 0;

}

.page {

min-height: 100vh;

display: -webkit-box;

display: -ms-flexbox;

display: flex;

-webkit-box-orient: vertical;

-webkit-box-direction: normal;

-ms-flex-direction: column;

flex-direction: column;

-ms-flex-pack: distribute;

justify-content: space-around;

}

.page__demo {

-webkit-box-flex: 1;

-ms-flex-positive: 1;

flex-grow: 1;

}

.main-container {

max-width: 960px;

padding-left: 2rem;

padding-right: 2rem;

margin-left: auto;

margin-right: auto;

}

.page__container {

padding-top: 30px;

padding-bottom: 30px;

max-width: 800px;

}

.footer {

padding-top: 1rem;

padding-bottom: 1rem;

text-align: center;

font-size: 1.4rem;

}

.footer__link {

text-decoration: none;

color: inherit;

}

@media screen and (min-width: 361px) {

.footer__container {

display: -webkit-box;

display: -ms-flexbox;

display: flex;

-webkit-box-pack: justify;

-ms-flex-pack: justify;

justify-content: space-between;

}

}

@media screen and (max-width: 360px) {

.melnik909 {

display: none;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值