css手机端图片截取 object-fit: cover;

电脑端案例效果:
在这里插入图片描述
手机端案例效果:
在这里插入图片描述

<!DOCTYPE html>  
<html>  
<head>  

</head>  
<body>  
<a href="" class="container">  

  <div class="background-image1">  
    <img src="11.jpg" alt="背景图">  
  </div> 
<div class="overlay222"></div> 
<div class="text textpageboll">
<div class="fading-images-overlay__title aatitle--1">Thank you for being a part of our journey.  We look forward to co-creating a brighter sexual health future with you.</div>
<div class="fading-images-overlay__title aatitle--2">DISCOVER MORE ABOUT LOVETOY</div>
</div>  

</a> 

</body>  
<style>  
body {  
  margin: 0;  
  padding: 0;  
  font-family: Arial, sans-serif;  
}  
  
.container {  
  position: relative;  
  width: 100%;  
  height: 422.5px;
  display: block;
}  
@media only screen and (min-width: 590px){
.container  {
height: 650px;
}
.aatitle--2 {
    width: 80%;
}
}

.background-image1 img {  
  position: absolute;  
  top: 0;  
  left: 0;  
  width: 100%;  
  height: 100%;  
  object-fit: cover;  
}  
  
.textpageboll {  
  position: absolute;  
  color: #fff;  
  font-size: 20px;  
  bottom: 6%;  z-index: 9999;
  left: -1px; right:-1px; 
  /*transform: translate(-50%, -50%);  */
}  
  
.overlay222 {  
  position: absolute;  
  top: 0;  
  left: 0;  
  width: 100%;  
  height: 100%;  
  background: rgba(0, 0, 0, 0.5); /* 黑色半透明背景 */  
  z-index: 1;  
}  
  .aatitle--1 {
    font-weight: 600;
    color: #fff;
    font-size: 1.1em;
    text-align: center;
}
.aatitle--2 {width: 28%;
    font-size: 1.1em;
    display: block;
    border: 1px solid #ffffff;
    text-align: center;
    margin-top: 15px;
    margin-right: auto;
    margin-left: auto;
    padding: 10px;
}
.aatitle--2 {
  text-align: center;
    font-weight: 600;
    color: #fff;
}
.aatitle--2:hover {
    background-color: #c11078;
}
/* 响应式布局 */  
@media (max-width: 600px) {  
  .text {  
    font-size: 16px; /* 根据需要调整字体大小 */  
  }  
}  
@media (max-width: 400px) {  
  .text {  
    font-size: 14px; /* 根据需要调整字体大小 */  
  }  
}  
</style>  
  • 23
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

linlinlove2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值