去除图片的宽高
- 匹配宽高
(width|height)=["']\d+["']
- 只匹配图片的宽高
str.replace(/(<img.*?)((width)=[\'"]+[0-9|%]+[\'"]+)/g, '$1').replace(/(<img.*?)((height)=[\'"]+[0-9|%]+[\'"]+)/g, '$1')
- 直接写样式覆盖
.box {
img {
width: 100%;
height: 100%;
}
}
去除图片的宽高
(width|height)=["']\d+["']
str.replace(/(<img.*?)((width)=[\'"]+[0-9|%]+[\'"]+)/g, '$1').replace(/(<img.*?)((height)=[\'"]+[0-9|%]+[\'"]+)/g, '$1')
.box {
img {
width: 100%;
height: 100%;
}
}
本文标题:图片正则
本文链接:https://www.haomeiwen.com/subject/vijbtqtx.html
网友评论