首页 > 代码库 > 图片展示失效容错处理
图片展示失效容错处理
用于当css样式失效时,能以文字显示内容提示,起个容错的处理】
<a class="bg" href="#">淘宝网</a>
方法一:设置text-indent
.bg { width: 140px; height: 40px; background-image: url(‘taobao.jpg‘); /*设置以下即可*/ text-indent: 9999px; /*使文字缩进溢出隐藏*/ white-space: nowrap; /*不换行*/ overflow: hidden; /*溢出隐藏*/}
方法二、设置padding-top,height
.bg { width: 140px; background-image: url(‘taobao.jpg‘); /*通过设置height为0,和合适的padding-top,将文字向下挤出*/ height: 0; padding-top: 40px; /*将挤出的文字隐藏*/ overflow: hidden;}
图片展示失效容错处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。