一个文字在一个图片上水平居中,并且悬浮变大特效

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
* {
padding: 0;
margin: 0;

}

img {
transition: all.5s;
-webkit-transition: all.5s;
-moz-transition: all.5s;
-ms-transition: all.5s;
-o-transition: all.5s;
transform: scale(1);

}

img:hover {
transform: scale(1.05);
}

.box {
position: relative;
width: 310px;
height: 130px;

}

span {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%);
background-color: red;
}
</style>
</head>

<body>


<div class="box">
<img src="./img/renzheng-2.jpg" alt="">
<span>文字</span>
</div> 

</body>

</html>
posted @ 2018-09-24 11:02  萌萌0104  阅读(546)  评论(0编辑  收藏  举报