<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
.wrap { | |
width: 230px; | |
height: 230px; | |
background-color: turquoise; | |
margin: 50px auto; | |
border-radius: 50%; | |
/* 子绝父相 */ | |
position: relative; | |
border-top: 10px solid #1ad280; | |
border-left: 10px solid #1ad280; | |
border-right: 10px solid #ecab18; | |
border-bottom: 10px solid #ecab18; | |
transition: 1s; | |
} | |
.wrap img { | |
width: 230px; | |
height: 230px; | |
border-radius: 50%; | |
transition: 1s; | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
} | |
.wrap .mask { | |
width: 230px; | |
height: 230px; | |
border-radius: 50%; | |
background-color: rgba(0, 0, 0, .4); | |
color: #fff; | |
font-style: italic; | |
text-align: center; | |
line-height: 230px; | |
font-size: 30px; | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
transition: 1s; | |
opacity: 0; | |
} | |
/* 大盒子旋转180度,里面子元素逆时针旋转180deg */ | |
.wrap:hover { | |
transform: rotate(180deg); | |
} | |
.wrap:hover .mask { | |
transform: rotate(-180deg); | |
opacity: 1; | |
} | |
.wrap:hover img { | |
transform: rotate(-180deg); | |
} | |
</style> | |
</head> | |
<body> | |
<!-- 把边框写在父盒身上 --> | |
<div class="wrap"> | |
<!-- 图片 --> | |
<img src="../../day25/day25作业/images/花.jpg" alt=""> | |
<!-- 遮罩层 --> | |
<div class="mask">flower</div> | |
</div> | |
</body> | |
</html> |