css - 如何通过 src 设置图像标签的样式?
问题描述
我有一个图像标签,例如,
<img src="image/path/goes/here/random_id">
并且 random_id 随机变化。如何在不使用 id、class 或任何其他属性的情况下从外部 css 文件中捕获此标记。
解决方案
您可以根据此在 src 属性上使用路径包含选择器
https://www.w3schools.com/cssref/sel_attr_contain.asp
img[src*="image/path/goes/here/"]{
border:1px solid red;
min-width:50px;
min-height:50px;
}
<img src="image/path/goes/here/123">
<img src="image/path/goes/here/321">
<img src="this/is/another/path/321">
推荐阅读
- javascript - 图像部分的动态(非冻结)着色
- java - 什么是 Java vmoptions 文件?哪个库/包装器支持这种文件格式来启动 java?
- elasticsearch - Elasticsearch 索引中非唯一 ID 的影响是什么?
- java - 在activi 7.x 版本中替代getFormService() 和getIdentifyService()
- python - matplotlib:如何从辅助轴中删除刻度和刻度值?
- android - 如何在 android 库 (aar) 中包含 jar 文件的许可证
- hadoop - 无法使用 hbase-shaded-client jar,因为它内部依赖于 log4j-1.2.17(CVE-2019-1757)
- powerbi - Power Bi Dax:在上个月的 2 个日期之间过滤
- c# - 如何在 EntityFramework 中重新加载实体?
- python - pandas dataframe: failed to apply lambda function to create new column based on condition if NaN or NA or \n or \t etc then 'No' else 'Yes'