问题
How can I tell VSCode to automatically add vendor prefixed style properties when adding a property without vendor prefixes added in CSS files (not SASS nor LESS files)?
回答1:
I have been using css-auto-prefix plugin. For most of the CSS3 properties it works fine. Though still in beta version, improvements are going on.You should try this one, it saves time and energy.
Perform following steps to install css-auto-prefix plugin in vscode.
- Open VS Code.
- Click Ctrl+Shift+X(on windows) or click on extensions icon on the left most panel.
- A search box will appear. Simply type css-auto-prefix.
- Install and Reload and you are good to go.
css-auto-prefix
回答2:
I have been using VS Code Autoprefixer plugin. It supports CSS, SCSS and SASS.
Select all CSS, then hit command pallet, then hit AutoPrefixer: Run
.
If nothing happens, then add this below section in settings.json
for Autoprefixer -
"autoprefixer.options": {
"browsers": [
"last 4 versions",
"ie >= 9",
"> 5%"
]
}
After that select all CSS, then hit command pallet, then hit AutoPrefixer: Run
and it will work.
回答3:
You can install "Auto prefix" or "Css Auto Prefix" Extension in your vs code but I am not quite sure if it would be ok to write our own snippest for the prefix maybe that way it will be more customizable.
But we also can always install "auto prefix"
via NPM a Node package manager.
来源:https://stackoverflow.com/questions/50928781/enable-vendor-prefix-autocomplete-in-css-files-in-visual-studio-code