文字描边实现内黄外绿效果

网页使用

<!DOCTYPE html>
<html>
<head>
<style>
.text-effect {
    color: #ffd700;      /* 黄色文字 */
    -webkit-text-stroke: 2px #008000;  /* 绿色描边(兼容Webkit内核) */
    text-stroke: 2px #008000;          /* 标准语法 */
    font-size: 40px;     /* 推荐使用较大字号 */
    font-weight: bold;   /* 粗体显示更清晰 */
    font-family: Arial, sans-serif; /* 无衬线字体效果更好 */
}

/* 布局样式(根据需求调整) */
.container {
    padding: 20px;
    background: white;
}
</style>
</head>
<body>
<div class="container">
    <div class="text-effect">收件人</div>
    <div class="text-effect">手机</div>
    <div class="text-effect">省市区</div>
    <div class="text-effect">地址</div>
</div>
</body>
</html>

微信小程序使用

上述代码运行换到微信小程序就会发现多了很多装饰线网格线等等,满足不了我们的需求,上述代码在网页上面使用无任何问题,微信小程序推荐下面的写法

<!-- WXML -->
<view class="container">
  <view class="text-effect">收货人</view>
  <view class="text-effect">手机</view>
  <view class="text-effect">省市区</view>
  <view class="text-effect">地址</view>
</view>
/* WXSS */
.container {
  padding: 20rpx;
  background: transparent; /* 确保父容器透明 */
}

.text-effect {
  color: #ffd700;         /* 黄色文字 */
  font-size: 40rpx;
  font-weight: bold;
  text-shadow: 
    -1px -1px 0 #008000,  /* 绿色外框 */
    1px -1px 0 #008000,
    -1px 1px 0 #008000,
    1px 1px 0 #008000;
  text-decoration: none;   /* 关键:移除装饰线 */
  font-family: Arial, sans-serif; /* 使用标准字体 */
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

萧寂173

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

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

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

打赏作者

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

抵扣说明:

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

余额充值