通过twitter bootstrap网站上给出的示例,以下代码
<div class="card">
<img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
<div class="card-block">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Button</a>
</div>
</div>
应该会产生一张漂亮的卡片,但是会产生
谁能说出问题所在?似乎数据属性对我不起作用。
我认为@bsmp是正确的答案。
然后,持有人将处理具有特定src属性(例如)的所有图像src="holder.js/318x180"
,并data-src
自动在其中生成图像源作为属性。
使用以下代码在页面中包含所有者:
<script src="https://cdn.jsdelivr.net/holder/2.9.0/holder.min.js"> </script>
您也可以从https://github.com/imsky/holder下载holder.js。
使用元素的src
属性img
来定义您的持有人图像:
<img class="card-img-top" src="holder.js/318x180" alt="Card image cap"> <div class="card-block">
请注意,src
对于最新版本的holder.js ,您不必在属性中转义holder语法。
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card" style="width:318px;">
<img class="card-img-top" src="holder.js/318x180" alt="Card image cap">
<div class="card-block">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Button</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/holder/2.9.0/holder.min.js"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句