CSS:
.posting-logo-div { }
.posting-logo-img { height:120px; width:120px; }
.posting-photo-div { height:5px;width:5px;position:relative;top:-140px;left:648px; }
.posting-photo-img { height:240px; width:240px; }
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="image" class="posting-logo-div"><img src="../images/some-logo1.jpg" onerror="this.src='../images/no-logo-120.jpg';" class="posting-logo-img"></div>
<div id="photo" class="posting-photo-div"><img src="../images/some-logo2.jpg" onerror="this.src='../images/no-logo-240.jpg';" class="posting-photo-img"></div>
Run Code Online (Sandbox Code Playgroud)
这在Chrome或Mozilla中似乎不起作用,但在IE中可以使用.
我有这段代码.
<img data-bind="attr: {src: 'imagePath'}, style: { 'background-image': 'url('imagePath')' }" class="img-responsive">
Run Code Online (Sandbox Code Playgroud)
问题是它显示两个图像.一个是src来自background图像的图像和来自图像的另一个图像.我的目标是background在src图像不可用时启用图像.