CSS 超长文本的隐藏和鼠标覆盖后显示

29 篇文章 0 订阅
13 篇文章 0 订阅

在 BootStrap Table 实践中,数据文本过长导致文本本身溢出表格区域,为了实现鼠标覆盖能够显示文本,正常状况下省略显示。

CSS 文件,代码示例:

.hiddenOverFlowCoverShow:hover
{
    width: 225px;
    font-size: 12px;
    border: 0px solid #ddd;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    color:blue;
    text-decoration:underline;
    cursor:pointer;
}
.hiddenOverFlowCoverShow{
    width: 225px;
    font-size: 12px;
    border: 0px solid #ddd;
    color:#5f5f5f;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}
JSP 文件,BootStrapTable 代码示例:
{
    field: 'orderRemark',
    title: '备注',
    align: 'center',
    formatter:function(value,row,index){
        var $remark = row.orderRemark;
        var a = '<label class="hiddenOverFlowCoverShow" title='+"'"+$remark+"'"+
                '>'+
                "'"+ $remark +"'"+'</label>'
        return a;
    }
}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现多张Vue悬停图片时覆盖图片显示隐藏文本内容,你可以使用Vue的绑定指令和CSS样式来实现。 首先,在HTML中使用v-for指令循环遍历图片数组,使用v-bind指令将每个图片的路径绑定到img标签的src属性上,同时给每个图片添加一个class名,用来控制CSS样式。 ```html <div class="container"> <div v-for="(img, index) in images" :key="index" class="image-wrapper"> <img :src="img.src" :class="'img-' + index"> <div class="text">{{img.text}}</div> </div> </div> ``` 接下来,在CSS中设置图片的样式,将图片的position属性设置为relative,将文本的position属性设置为absolute,然后使用z-index属性将文本的层级设置在图片上方。 ```css .container { display: flex; flex-wrap: wrap; justify-content: center; } .image-wrapper { position: relative; margin: 10px; } img { width: 200px; height: 200px; } .text { position: absolute; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); color: white; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; text-align: center; z-index: 1; } .img-0:hover + .text { display: flex; } .img-1:hover + .text { display: flex; } .img-2:hover + .text { display: flex; } /* 根据需要设置更多的图片和文本的样式 */ ``` 最后,在Vue中定义图片数组,每个图片包含一个src属性和一个text属性,分别表示图片路径和显示文本内容。 ```javascript new Vue({ el: '#app', data: { images: [ { src: 'img1.jpg', text: '这是第一张图片的文本内容' }, { src: 'img2.jpg', text: '这是第二张图片的文本内容' }, { src: 'img3.jpg', text: '这是第三张图片的文本内容' } ] } }) ``` 这样就可以实现多张Vue悬停图片时覆盖图片显示隐藏文本内容了。当鼠标悬停在图片上时,对应的文本内容会显示出来。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值