html5 css颜色标签,CSS3 颜色标签栏

这段CSS代码实现了一个网页背景颜色平滑过渡的效果,通过@import引入谷歌字体库,设置HTML和body的高度及溢出隐藏。h1元素居中显示,使用Droid Serif字体。四个div元素分别对应四种不同的背景颜色,通过input[type='radio']来切换显示。当点击某个radio按钮时,对应的div会从左侧滑入,呈现出平滑过渡效果。
摘要由CSDN通过智能技术生成

CSS

语言:

CSSSCSS

确定

@import url(https://fonts.googleapis.com/css?family=Droid+Serif);

html, body {

height: 100%;

position: relative;

overflow: hidden;

}

h1 {

position: absolute;

top: 50%;

left: 50%;

-webkit-transform: translate(-50%, -50%);

transform: translate(-50%, -50%);

font-size: 1.7rem;

font-family: "Droid Serif";

text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);

line-height: 1.2;

color: #fff;

z-index: 2;

}

div {

position: absolute;

top: 0;

left: 0;

width: 100%;

height: 100%;

-webkit-transition: -webkit-transform 0.4s ease;

transition: -webkit-transform 0.4s ease;

transition: transform 0.4s ease;

transition: transform 0.4s ease, -webkit-transform 0.4s ease;

-webkit-transform: translateX(-100%);

transform: translateX(-100%);

}

div:nth-of-type(1) {

background-color: #f06868;

}

div:nth-of-type(2) {

background-color: #fab57a;

}

div:nth-of-type(3) {

background-color: #edf798;

}

div:nth-of-type(4) {

background-color: #80d6ff;

}

input[type="radio"] {

position: absolute;

left: 0;

width: 10px;

height: 25%;

outline: 10px solid;

outline-offset: -10px;

margin: 0;

z-index: 1;

cursor: pointer;

}

input[type="radio"]:nth-of-type(1) {

outline-color: #f06868;

top: 0%;

}

input[type="radio"]:nth-of-type(2) {

outline-color: #fab57a;

top: 25%;

}

input[type="radio"]:nth-of-type(3) {

outline-color: #edf798;

top: 50%;

}

input[type="radio"]:nth-of-type(4) {

outline-color: #80d6ff;

top: 75%;

}

input[type="radio"]:checked + div {

-webkit-transform: translateX(0%);

transform: translateX(0%);

-webkit-transition: -webkit-transform 0.4s ease 0.4s;

transition: -webkit-transform 0.4s ease 0.4s;

transition: transform 0.4s ease 0.4s;

transition: transform 0.4s ease 0.4s, -webkit-transform 0.4s ease 0.4s;

}

body{margin:0;}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值