css3价格斜切_CSS3+JS 两张图片斜切组合的效果

这篇博客介绍了如何使用CSS3和JavaScript创建一个独特的斜切效果,将两张图片完美结合。通过设置绝对定位、变换属性和过渡效果,实现了两个图片容器的斜切展示。同时,文章中还展示了如何添加交互按钮,随着按钮状态的变化,图片和按钮的样式也会有相应的动态效果。
摘要由CSDN通过智能技术生成

CSS

语言:

CSSSCSS

确定

body {

color: #444;

font-size: 18px;

}

.hero {

position: relative;

width: 100%;

height: 500px;

overflow: hidden;

}

.image-container {

display: block;

position: absolute;

width: 120%;

height: 100%;

transform: skew(-20deg);

overflow: hidden;

}

.image-container.image-1 {

display: block;

right: 50%;

z-index: 1;

}

.image-container.image-1 .image {

background-image: url(http://ericbrewer.ca/images/stockImages/newYork.jpg);

transform: skew(20deg) translateY(-300px) translateX(200px);

}

.image-container.image-2 {

left: 50%;

z-index: 2;

}

.image-container.image-2 .image {

background-image: url(http://ericbrewer.ca/images/stockImages/wheatField.jpg);

margin-left: -100px;

transform: skew(20deg) translateY(300px) translateX(-200px);

}

.image {

display: block;

width: 130%;

height: 100%;

background: transparent no-repeat center center;

background-size: cover;

transform: skew(20deg);

transition: all .3s ease-out;

opacity: 0;

}

.image.active {

transform: skew(20deg) !important;

opacity: 1;

}

.btn {

display: block;

position: absolute;

top: 60%;

left: 50%;

width: 200px;

height: 60px;

line-height: 60px;

padding: 0;

text-align: center;

font-size: 20px;

text-transform: uppercase;

color: white;

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

opacity: 0;

z-index: 1000;

box-shadow: none !important;

border-radius: 0 !important;

overflow: hidden;

}

.btn:after {

display: block;

position: absolute;

top: 50%;

left: 50%;

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

content: "";

background: white;

width: 10px;

height: 10px;

border-radius: 50%;

opacity: 0;

z-index: -1;

transition: all .4s ease-out;

}

.btn.active {

opacity: 1;

transition: all .3s ease-out, opacity .2s .5s ease-out;

}

.btn.active:hover {

color: #62757f;

}

.btn.active:hover:after {

opacity: 1;

width: 300px;

height: 200px;

}

.btn.active .side {

opacity: 1;

}

.btn.active .top,

.btn.active .bottom {

width: 100% !important;

}

.btn.active .left,

.btn.active .right {

height: 100% !important;

}

.btn .side {

display: block;

position: absolute;

background: white;

content: "";

transition: all .3s .5s ease-out;

opacity: 0;

}

.btn .side.top {

top: 0;

left: 0;

width: 0%;

height: 2px;

}

.btn .side.bottom {

bottom: 0;

right: 0;

width: 0%;

height: 2px;

}

.btn .side.left {

bottom: 0;

left: 0;

width: 2px;

height: 0%;

}

.btn .side.right {

top: 0;

right: 0;

width: 2px;

height: 0%;

}

h1 {

display: block;

position: relative;

top: 25%;

text-transform: uppercase;

z-index: 101;

color: white;

font-size: 60px;

font-style: italic;

width: 100%;

}

h1 span {

opacity: 0;

}

h1.active span {

opacity: 1;

transform: translateY(0px) !important;

transition: all .3s .5s ease-out;

}

h1 .demi {

position: absolute;

right: 50%;

transform: translateY(100px) translateX(-40px);

}

h1 .hero {

position: absolute;

left: 50%;

transform: translateY(-100px) translateX(40px);

}

p {

text-align: center;

font-size: 22px;

line-height: 30px;

max-width: 80%;

margin: 60px auto;

}

i {

position: relative;

font-size: 16px !important;

margin: 0 10px;

}

i:after {

display: block;

position: absolute;

width: 25px;

height: 25px;

border: 1px solid #444;

content: "";

top: -50%;

left: -100%;

border-radius: 50%;

border-top-color: transparent;

border-bottom-color: transparent;

animation: expand 1s ease-out infinite;

}

@keyframes expand {

0% {

opacity: 0;

transform: scale(0.5);

}

10% {

opacity: 1;

}

100% {

opacity: 0;

transform: scale(1);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值