css3實現滑鼠移上去放大效果
07-14
css3實現滑鼠移上去放大效果
推薦閱讀:
1,最近因公司在用react來做移動端的項目,所以這久寫了很多樣式,於是決定最近寫一些特效,只能算做一種筆記。
2,實現思路最主要是有二張圖片,第二張隱藏,並將其定位,移上去將其顯示,其實就這樣很簡單。
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8">
<meta name="viewport" content="width_=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .box{ width: 1024px; height: 600px; margin: 200px auto; }.list{
float: left; margin-left: 5px; margin-top: 20px; position: relative; margin-bottom: 10px; } .box img{ width: 100px; height: 100px;border: 1px solid #000;
padding: 2px; background: #fff; display: block; } .box img:nth-of-type(2){ width: 200px; height: 200px; position: absolute; top: -50px;left: -50px;
z-index: 10; display: none; } .list:hover img:nth-of-type(2){ display: block; } </style></head><body>
<div class="box"> <div class="list"> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> </div><div class="list">
<img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> </div> <div class="list"> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/>
</div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> </div><div class="list">
<img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> </div> <div class="list"> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/><img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/>
</div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> </div> <div class="list"> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> </div> <div class="list"> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> </div> <div class="list"> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> </div> <div class="list"> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> </div> <div class="list"> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> </div> <div class="list"> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> <img src="https://f12.baidu.com/it/u=3087422712,1174175413&fm=72"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530726278076&di=77a3363440341cc5f06551bcd8612741&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F0823dd54564e92584fbb491f9082d158cdbf4eb0.jpg"/> </div> <div class="list"> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> <img src="https://f11.baidu.com/it/u=2465775762,1509670197&fm=72"/> </div> <div class="list"> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> <img src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1181062145,1954327019&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531321124&di=34b664a35c89eecb236e25f067ea9b5e&imgtype=jpg&er=1&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F88%2Fd%2F179.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=297766146,972316190&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2032549940,4190326168&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=857364271,2253852884&fm=27&gp=0.jpg"/> </div> <div class="list"> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> <img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=4074087862,2822681127&fm=200&gp=0.jpg"/> </div> </div></body></html>4,自行複製代碼查看效果,一起學習一起成長,我會將我在公司學到的記錄在這裡。
推薦閱讀:
TAG:滑鼠 | 羅技Logictech | 遊戲滑鼠 |