CSS常遇到自适应高度动画、带三角气泡阴影一行样式解决

效果图

.wxml

复制代码
<!-- 滤镜阴影 -->
<view class="container dropShadow" />
<!-- 盒子阴影 -->
<view class="container boxShadow" />
<!-- 文本阴影 -->
<view class="textShadow">换日线</view>
<!-- 自适应高度过渡动画 -->
<button bind:tap="updateDrop">{{drop?'收起':'展开'}}</button>
<view class="clipPath {{drop?'clipPathAction':''}}">
  <text>https://blog.csdn.net/qq_43764578\n占位\n占位\n占位\nhttps://blog.csdn.net/qq_43764578\n占位\n占位\n占位</text>
</view>

.wxss

复制代码
page{text-align: center;}
.container{
  width: 300rpx;
  height: 100rpx;
  border-radius: 20rpx;
  background: #99CCFF;
  position: relative;
  margin: 100rpx auto 0;
}
.container::after{
  content: '';
  width: 0;
  height: 0;
  border: 10px solid transparent;
  border-right-color: #99CCFF;
  position: absolute;
  left: -20px;
  top: 0;
  bottom: 0;
  margin: auto 0;
}
.dropShadow{
  filter: drop-shadow(0 0 10rpx red);
}
.boxShadow{
  box-shadow:0 0 10px red;
}
.textShadow{
  text-shadow: 0 0 2px red;
  margin: 100rpx auto 50rpx;
}
.clipPath{
  background: #99CCFF;
  padding: 30rpx;
  box-sizing: border-box;
  width: 600rpx;
  margin: 30rpx auto 0;
  clip-path: inset(0 0 100% 0);
  transition: all 0.3s;
}
.clipPathAction{
  clip-path: inset(0 0 0 0);
}

.js

复制代码
Page({
  data: {
    drop:false
  },
  updateDrop(){
    this.setData({
      drop:!this.data.drop
    })
  },
})

遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
触底反弹1 小时前
🎲 纯 CSS 搞定 3D 旋转立方体?还附赠一个「天坑」解决方案!
前端·css·html
finyouIT2 小时前
锚点实现了点击导航平滑滚动到页面指定位置的三种方法
javascript·css
用户059540174465 小时前
用了半年 LangChain Memory,才发现记忆总“串台”——3 个自动化测试避坑指南
前端·css
More more6 小时前
纯手搓css样式:科技感弹窗边框
css·科技·css3
kidding7231 天前
旋转大转盘小程序
前端·css·微信小程序·小程序·前端框架
用户059540174461 天前
AI 客服突然“失忆”,排查 6 小时发现 LangChain 记忆存储的 3 个致命坑
前端·css
晓得迷路了1 天前
栗子前端技术周刊第 136 期 - pnpr、Flow 重构移植 Rust、Astryx...
前端·javascript·css
丨我是张先生丨1 天前
英语单词 Web Page
前端·css·css3
疯狂的魔鬼2 天前
精确计算容器剩余视口高度:useAutoContainerFullHeight 的工程实践
前端·css·typescript
用户059540174462 天前
用了 3 个月 ChatGPT,才发现它一直在遗忘——用 Playwright 自动化验证记忆存储一致性
前端·css