Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 图像不可用时仅显示文本_Html_Css_Angular_Url - Fatal编程技术网

Html 图像不可用时仅显示文本

Html 图像不可用时仅显示文本,html,css,angular,url,Html,Css,Angular,Url,我想在没有图像时显示文本 所以我有一个css: .msgdownload { position: relative; width: 25px; height: 25px; display: block; } .msgdownload::after { content:''; position: absolute; top: 0; right: 0; width: 100%; height: 100% ; background: url('') no-repeat bottom

我想在没有图像时显示文本

所以我有一个css:


.msgdownload {
  position: relative;
  width: 25px;
  height: 25px;
  display: block;
}

.msgdownload::after {
content:'';
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100% ;
background: url('') no-repeat bottom;
}

.msgdownload > p {
  position: relative;
  z-index: -1;
}

这是我的html。来自表格C#:

如何更改此选项:

   return $"<a href = \"{baseUrl}api/Devices/GetDownload/{model.AttachmentKey}/\" alt=\"Download\"  class=\"msgdownload\"></a>";
return$“”;
但如果我这样做:

      return $"<a href = \"{baseUrl}api/Devices/GetDownload/{model.AttachmentKey}/\" alt=\"Download\"  class=\"msgdownload\"><img src=\"#\" alt=\"download\" /></a>";
return$“”;

而且图像也可以使用。然后您将看到文本和图标。

首先,除了img之外,您不能为a标记使用替代文本。也许,正是这一点让你陷入困境

<img src="..." alt="Text Here" />

我希望它能帮助你。

我这样解决:

return $"<a href = \"{baseUrl}api/Devices/GetDownload/{model.AttachmentKey}/\" class=\"msgdownload\"><img src='./images/downloadIcon.jpg' alt=\"Download\"/></a>";


什么形象?此处引用的图像:
background:url(“”)无重复底部?是的,因此我删除了指向imageWell的链接。您无法检查CSS中是否存在文件。因此,您可能需要检查图像是否在服务器端(C#)可用,然后如果它存在,请在链接中添加一个CSS类,该类将具有您的背景图像样式。但是如何做到这一点?但是我在Angular项目中有图像?但我有一个“美元”;但您使用的是链接标记。尝试使用imgyes,oke,但现在我无法下载,我无法单击它
<img src="..." alt="Text Here" />
return $"<a href = \"{baseUrl}api/Devices/GetDownload/{model.AttachmentKey}/\" class=\"msgdownload\"><img src='./images/downloadIcon.jpg' alt=\"Download\"/></a>";

.msgdownload::after {
content:'';
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100% ;
}