html图片旁边加文字

利用在文字旁边创建盒子然后调整盒子的位置找到文字在图片边

具体代码如下

<!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>淘宝</title>
    <link rel="stylesheet" href="tb.css">
</head>
<body>
    <div class="box">
        <img src="tp.webp" alt="1">
  <div class="box2">
    <span class="text">
        <span>象有秘密</span> <span>中式</span><span>陶瓷研磨碗厨房捣蒜器手动研磨器家用蒜泥碾磨芝麻</span>
      </span>
  </div>
  <div class="box3">
    <span class="text2">送运费险</span>
  </div>
  <div class="box4">
    <span class="text3">¥22.5</span>
  </div>
  
    </div>
</body>

css代码如下

主要方法就是大盒子包小盒子

很简单的方法

其他的方法也有但是这是其中的一个

.box{
    width: 400px;
    height: 200px;
    background-color: rgb(255, 255, 255);
    border: 2px solid rgb(255, 77, 0);
    box-sizing:border-box;  
    border-radius: 20px; 
     }
     .box2{
        width: 200px;
        height: 70px;
        background-color: rgb(255, 255, 255);
        margin-right: 80px;
        margin-left: 190px;
        margin-top: -180px;
     }
     .box3{
        width: 80px;
    height: 30px;
    background-color: rgb(255, 255, 255);
    border: 2px solid rgb(255, 77, 0);
    box-sizing:border-box;  
    border-radius: 10px; 
    margin-right: 50px;
    margin-left: 200px;
    margin-top: 0px;
     }
     .box4{
        width: 80px;
    height: 30px;
    background-color: rgb(255, 255, 255);
    margin-right: 50px;
    margin-left: 200px;
    margin-top: 20px;
     }

     img{
        width: 170px;
        height: 170px;
        border-radius: 20px; 
        box-shadow:2px 2px 15px;
        margin-right: 15px;
        margin-left: 15px;
        margin-top: 15px;
     }
     .text{
      width: 200px;
      height: 100px;
      
      vertical-align: middle;
     }
     .text2{
     color: rgba(255, 60, 0, 0.836);
     text-align: center;
       }
       .text3{
        font-size: 30px;
        color: red;
        text-align: center;
          }

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值