时间:2023-03-06来源:系统城装机大师作者:佚名
当我们想在图片上面放置一些文字内容时,发现不管怎么放置,要么就是图片影响到文字的观感,要么就是文字挡住图片的细节,那么怎么可以既看到图片的细节又可以看到对图片的文字描述呢?下面一起来看看吧。
实现效果

我们需要将外层的盒子设置相对定位,将其子盒子设置绝对定位,形成子绝父相,当我们触摸图片时,通过 bottom 属性搭配 transition 属性让其以丝滑的动画实现图片上升显示描述的效果。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45  | 
			<template>  <div class="parentBox">    <div class="imgBox">      <img src="https://i.postimg.cc/4xxZNsL6/1677486088618.png">    </div>    <div class="contantBox">详细内容</div>  </div></template><style scoped>.parentBox {  box-shadow: 2px 2px 8px -1px cornflowerblue;  width: 200px;  height: 200px;  position: relative;  cursor: pointer;}.imgBox {  position: absolute;  width: 100%;  height: 100%;  z-index: 20;  -webkit-transition: all 0.5s ease;  transition: all 0.5s ease;  bottom: 0;}img {  width: 100%;  height: 100%;}.parentBox:hover .imgBox {  bottom: 60px;}.contantBox {  padding: 4px;  color: white;  width: 100%;  height: 60px;  background: cornflowerblue;  position: absolute;  bottom: 0;}</style> | 
		
到此这篇关于纯CSS实现鼠标悬停图片上升显示描述案例的文章就介绍到这了
2023-03-06
css3鼠标滑过实现动画线条边框2023-03-06
css scroll-snap控制滚动元素的实现2023-03-06
CSS实现多层嵌套列表自动编号的示例代码传统的灰色纯色边框你是不是觉得太难看了?你是否想设计一些精美的边框,例如渐变、圆角、彩色的边框?那你来对地方了,本文将介绍如何用纯CSS就能实现具有渐变和圆角的彩色边框...
2023-03-06
今天给大家带来一个如何实现圆角三角形的方案,这个方案虽然可以实现,但是也是借助拼凑等方式来实现的,假如想一个div来实现圆角三角形,还是比较困难的。之前文章讲了如何实现对话框,里面介绍了三角形的实现方式。今天讲讲...
2023-03-06