定位后被遮挡,我解决方案是用z-index,但是发现还是被遮挡,求助各位师傅。
wxml:
<view class="container">
<view class="page-body">
<swiper class="body-pic" indicator-dots="true" autoplay="ture" interval="2000">
<swiper-item> <image src='/images/bg7.jpg'></image></swiper-item>
<swiper-item> <image src='/images/bg2.jpg'></image></swiper-item>
<swiper-item> <image src='/images/bg3.jpg'></image></swiper-item>
</swiper>
</view>
<view class='notice-wrap' hidden='{{hideNotice}}'>
<view class='tongzhitext'>
<text class="tongzhi-text">{{notice}}</text>
</view>
<text bindtap='switchNotice' class="closeView">x</text>
</view>
</view>
wxss:
.container {
height: 100%;
display: flex;
flex-direction: column;
padding: 0;
box-sizing: border-box;
}
.page-body{
width: 100%;
}
.body-pic{
width: 100%;
height: 250px;
}
.body-pic image{
width: 100%;
height: 250px;
}
/* 公告 */
@keyframes remindMessage {
0% {
-webkit-transform: translateX(90%);
}
100% {
-webkit-transform: translateX(-180%);
}
}
.tongzhitext {
margin-right:80rpx;
margin-left: 10rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
z-index:1;
}
.tongzhi-text {
font-size: 28rpx;
animation: remindMessage 14s linear infinite;
width: 100%;
color: #d09868;
display: block;
position: relative;
top: -55px;
z-index:9999;
}
.notice-wrap {
background: #ffebda;
width: 100%;
height: 60rpx;
line-height: 60rpx;
color: #d09868;
font-size: 28rpx;
z-index:1;
}
.closeView {
width: 45rpx;
height: 45rpx;
line-height: 45rpx;
position: absolute;
right: 20rpx;
top: 5rpx;
text-align: center;
font-size: 35rpx;
position: absolute;
left:95%;
top:245px;
z-index:999;
}
是这个效果吗(不知道你想要的效果是啥)
/* 公告 */ @keyframes remindMessage { 0% { -webkit-transform: translateX(90%); } 100% { -webkit-transform: translateX(-180%); } } .notice-wrap { width: 100%; background: #ffebda; height: 100%; position: relative; color: #d09868; } .tongzhitext{ width: 90%; padding: 0 5%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .tongzhi-text { font-size: 28rpx; animation: remindMessage 14s linear infinite; width: 90%; height: 60rpx; display: flex; align-items: center; } .closeView { width: 45rpx; background: #ffebda; height: 45rpx; line-height: 45rpx; position: absolute; right: 0rpx; top: 0rpx; text-align: center; font-size: 35rpx; position: absolute; z-index: 999; }
若有帮助请帮忙点个"有用"谢谢↓↓
把你的有问题的代码照着这个文档 写一个代码片段出来
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
.tongzhitext { margin-right:80rpx; margin-left: 10rpx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; position: relative; z-index:1; } .tongzhi-text { font-size: 28rpx; animation: remindMessage 14s linear infinite; color: #d09868; display: block; } .notice-wrap { position: relative; background: #ffebda; width: 100%; height: 60rpx; line-height: 60rpx; color: #d09868; font-size: 28rpx; } .closeView { width: 45rpx; height: 45rpx; line-height: 45rpx; position: absolute; right: 20rpx; top: 5rpx; text-align: center; font-size: 35rpx; }
若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人
好奇怪,如果不用z-index是否有其他解决方案呢