html+css 在图片上添加文字

本文详细介绍了一种图书卡片的设计方案,使用了HTML和CSS技术,通过绝对定位和相对定位结合,实现了美观且响应式的图书展示效果。文章还解释了如何在页面中使用阴影效果、边框圆角等样式增强视觉体验。

html  

<view class="container">
    <image class="" src="{{book.image}}"></image>
    <view class="description">
        <text class="title">{{book.title}}</text>
        <text class="author">{{book.author}}</text>
        <view class='foot'>
            <text class="footer">{{book.fav_nums}}  喜欢</text>
        </view>
    </view>
</view>

css 

/* component/page/index.wxss */
.container {
   display: flex;
   flex-direction: column;
   align-items: center;
   margin-top: 30rpx;
   box-shadow: 2px  2px  3px #e3e3e3e3;
   position: relative;
   width: 240rpx;
   height: 360rpx;
}
.container image{
   width: 100%;
   height: 100%;
   border-radius: 2px;
}
.description {
  width: 100%;
  position:absolute; 
  z-index:2;
  left:0;
  bottom:0;
  background-color: white;
}

这里我们 使用到 position : absolute;同时设置 bottom:0;left:0;  来生成 绝对定位 因为我们这里   position : absolute 要生效,

相对于 static 定位以外的第一个父元素进行定位  所以我们 设置父元素为相对定位

 

 

转载于:https://www.cnblogs.com/guangzhou11/p/11462557.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值