【发布时间】:2020-11-15 19:05:43
【问题描述】:
我有运动方面的问题。 我做了一个有几个悬停的圆圈。 我想在这个 4 部分圆的背景中放一张图片(附代码),当它悬停时,这张图片应该分成 4 块,并且有一个拼图的形状。 我不会使用 HTML 和 CSS 运行。 enter image description here
* {
margin: 0;
padding: 0;
font-size: medium;
font-family: sans-serif;
box-sizing: border-box;
}
.Parent {
width: 40%;
padding-top: 40%;
background-color: darkorchid;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
div.piece {
background-color: darksalmon;
width: 50%;
padding-top: 50%;
position: absolute;
background-image: url(img/fire.jpg);
background-size: cover;
}
#pie-1 {
top: 0%;
left: 0;
border-top-left-radius: 100%;
transition: 1s;
transition: all 500ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
transition-timing-function: cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
background-position: left top;
}
#pie-2 {
top: 0%;
background-color: darkseagreen;
left: 50%;
border-top-right-radius: 100%;
transition: all 500ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
transition-timing-function: cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
background-position: right top;
}
#pie-3 {
bottom: 0;
left: 0;
border-bottom-left-radius: 100%;
background-color: darkslategray;
transition: all 500ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
transition-timing-function: cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
}
#pie-4 {
bottom: 0;
left: 50%;
border-bottom-right-radius: 100%;
background-color: darkviolet;
transition: all 500ms cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
transition-timing-function: cubic-bezier(0.600, -0.280, 0.735, 0.045);
/* easeInBack */
}
.Parent:hover #pie-1 {
transform: translate(-100%, -100%);
z-index: 2;
}
.Parent:hover #pie-2 {
transform: translate(100%, -100%);
z-index: 2;
}
.Parent:hover #pie-3 {
transform: translate(-100%, 100%);
z-index: 2;
}
.Parent:hover #pie-4 {
transform: translate(100%, 100%);
z-index: 2;
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div class="Parent">
<Div class="piece" id="pie-1"></Div>
<Div class="piece" id="pie-2"></Div>
<Div class="piece" id="pie-3"></Div>
<Div class="piece" id="pie-4"></Div>
</div>
【问题讨论】:
-
我做了一个使用 javascript jsbin.com/xixayiy/edit?html,css,js,output 的例子
-
感谢您的时间和考虑。