img[src=""] img标签无路径情况下,灰色边框去除解决方案
1.Js解决办法
<meta> <title></title> <img alt="详解img[src=""] img无路径情况下,灰色边框去除解决方法" > <script> function whenError(a){ a.onerror=null; a.src='path_default.jpg'; console.log('图片出错的时候调用默认的图片'); } </script>
2.绝对定位聚焦解决方案
nbsp;html> <meta> <title>absolute聚焦解决方案</title> <p> <img alt="详解img[src=""] img无路径情况下,灰色边框去除解决方法" > </p> <style> .container-img { position: relative; display: inline-block; width: 36px; height: 36px; overflow: hidden; } .container-img img { position: absolute; top: -1px; right: -1px; background: url(img/common-icon.png) no-repeat; background-position: 0px 1px; } </style>
3.margin聚焦解决办法
nbsp;html> <meta> <title>margin聚焦解决方案</title> <p> <img alt="详解img[src=""] img无路径情况下,灰色边框去除解决方法" > </p> <style> .container-img { display: inline-block; width: 36px; height: 36px; overflow: hidden; } .common-icon { display: inline-block; background: url(img/common-icon.png) no-repeat; background-position: 0px 1px; margin: -1px; } </style>
4.css隐藏
img[src=""]{ opacity: 0; }
以上就是详解img[src=""] img无路径情况下,灰色边框去除解决方法的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号