tailwind 中 @base 会设置 img 标签 height: auto。
img, video {
max-width: 100%;
height: auto;
}
这导致我文章里面的图片宽度被拉伸的和容器一样的宽度100%了。
我尝试覆盖为unset但是没用,其他什么initial 试了也不行
@layer base {
img, video {
height: unset;
}
}
tailwind 中 @base 会设置 img 标签 height: auto。
img, video {
max-width: 100%;
height: auto;
}
这导致我文章里面的图片宽度被拉伸的和容器一样的宽度100%了。
我尝试覆盖为unset但是没用,其他什么initial 试了也不行
@layer base {
img, video {
height: unset;
}
}
参考
https://github.com/tailwindlabs/tailwindcss/pull/7742
安装postcss-remove-rules
然后 postcss.config.js 配置
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
"postcss-remove-rules": {
rulesToRemove: {
"img,\nvideo": "height",
},
},
},
}