css自动前缀_CSS创意:/ *自动前缀* /

css自动前缀

Using utilities likes SASS and Compass have made me me think a lot about how we can improve CSS in the short term.  Of course all CSS proposals should go through the W3C standardization process, but the problem is that those processes take a long time.  We also know that there are a lot of things we know we need in CSS:

使用诸如SASS和Compass之类的实用程序让我思考了一下如何在短期内改进CSS。 当然,所有CSS提案都应经过W3C标准化过程,但问题是这些过程需要很长时间。 我们还知道CSS中有很多我们需要的东西:

  • CSS Variables

    CSS变量
  • Nested style blocks (a la SASS, LESS, etc.)

    嵌套样式块(如SASS,LESS等)
  • Macros / routines

    宏/例程

We know we need these things but still don't have them yet, and likely wont for years.  That got me to thinking about another problem:  the constant need to do the prefixing of properties for every browser, like this mess:

我们知道我们需要这些东西,但仍然还没有,而且可能多年都不会。 那让我开始思考另一个问题:不断需要为每个浏览器做属性前缀,就像这样:


#someElement {
	-moz-animation-name: myAnimation;
	-webkit-animation-name: myAnimation;
	-ms-animation-name: myAnimation;
	animation-name: myAnimation;
}


Firefox has un-prefixed a majority of previously prefixed properties, but we still can't get away from this mess for other browsers.  So how can we fix this in the short term, besides making browser vendors unprefix?  One idea is doing something kind of like JavaScript's use strict;  we start our CSS file with something like this comment:

Firefox取消了大多数先前带前缀的属性的前缀,但是对于其他浏览器,我们仍然无法摆脱这种混乱局面。 那么,除了让浏览器供应商取消前缀之外,我们如何在短期内解决此问题? 一种想法是做一些有点像 JavaScript的use strict ; 我们以如下注释开始CSS文件:


/*autoprefix*/



/* and then somewhere in the CSS file */
#someElement {
	animation-name: myAnimation;
}


If a CSS file started with this CSS comment, the browser would automatically prefix properties that required prefixing.  Since browsers know which properties need prefixing, and they only need to account for their prefix, this type of system would reduce code (and thus smaller/quicker file downloads) and, in theory, be much faster to implement.

如果CSS文件以该CSS注释开头,则浏览器将自动为需要添加前缀的属性添加前缀。 由于浏览器知道哪些属性需要加前缀,并且它们只需要考虑其前缀,因此这种类型的系统将减少代码(从而减少文件下载量/缩短文件下载时间),并且从理论上讲,实现起来要快得多。

Now this isn't a perfect solution by any means.  It should still be standardized at some point and unfortunately some prefixed properties act differently than unprefixed.  Just a thought that I wanted to share, get some feedback on.  Let me know if you think something like this would work!

现在无论如何这都不是完美的解决方案。 仍应在某些时候对其进行标准化,但不幸的是,某些带前缀的属性的行为与未带前缀的属性不同。 只是我想分享的想法,请提供一些反馈。 让我知道您是否认为这样的工作会成功!

翻译自: https://davidwalsh.name/css-idea-autoprefix

css自动前缀

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#page #content .tshop-pbsm-shop-nav-ch .skin-box-bd{background:none;height:30px;}#page #content .tshop-pbsm-shop-nav-ch .skin-box .skin-box-bd{background:none;border:none;}#page #content .tshop-pbsm-shop-nav-ch .all-cats .link{background:none;height:30px;line-height:30px;}#page #content .tshop-pbsm-shop-nav-ch .all-cats .link .popup-icon{margin-top:10px;}#page #content .tshop-pbsm-shop-nav-ch .all-cats .link{width:120px;}#page #content .tshop-pbsm-shop-nav-ch .menu-list .menu .link{line-height:30px;height:30px;padding:0 0px;}#page #content .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .snd-pop-inner .snd-cat-hd:hover .snd-cat-name,#page #content .tshop-pbsm-shop-nav-ch .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .snd-pop-inner .snd-cat-hd-hover .snd-cat-name{text-decoration:none;}#page #content .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .fst-cat:hover .fst-cat-name,#page #content .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .cat-hd-hover .fst-cat-name{text-decoration:none;}#page #content .tshop-pbsm-shop-nav-ch .menu-list .menu{padding-right:0;}#page #content .tshop-pbsm-shop-nav-ch .aitao-menu{display:none;}#page #content .tshop-pbsm-shop-nav-ch .menu-list .menu.menu-selected{background:#666;}#page #content .tshop-pbsm-shop-nav-ch .menu-list .menu .link .title{margin:0 8px;}#page #content .tshop-pbsm-shop-nav-ch .menu-list{width:820px;}#page #content .tshop-pbsm-shop-nav-ch .menu-list .menu .link:hover{background:none;color:#666;}#page #content .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .fst-cat:hover,#page #content .tshop-pbsm-shop-nav-ch .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .cat-hd-hover{background:#666;}#page #content .tshop-pbsm-shop-nav-ch .popup-content .cats-tree .snd-pop-inner{background-color:#666;}
const config = { base: './', // index.html文件所在位置 root: './', // js导入的资源路径,src resolve: { alias, }, define: { 'process.env': {} }, server: { // 如果使用docker-compose开发模式,设置为false open: true, port: process.env.VITE_CLI_PORT, proxy: { // 把key的路径代理到target位置 // detail: https://cli.vuejs.org/config/#devserver-proxy [process.env.VITE_BASE_API]: { // 需要代理的路径 例如 '/api' target: `${process.env.VITE_BASE_PATH}/`, // 代理到 目标路径 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_API), ''), }, [process.env.VITE_BASE_EXPORT_API]: { // 需要代理的路径 例如 '/api' target: `${process.env.VITE_BASE_REPORTAPI}/`, // 代理到 目标路径 changeOrigin: true, rewrite: path => path.replace(new RegExp('^' + process.env.VITE_BASE_EXPORT_API), ''), }, }, }, build: { target: 'es2017', minify: 'terser', // 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用terser manifest: false, // 是否产出manifest.json sourcemap: false, // 是否产出sourcemap.json outDir: 'dist', // 产出目录 // rollupOptions, }, esbuild, optimizeDeps, plugins: [ GvaPositionServer(), GvaPosition(), legacyPlugin({ targets: ['Android > 39', 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'], }), vuePlugin(), [Banner(\n Build based on gin-vue-admin \n Time : ${timestamp})] ], css: { preprocessorOptions: { scss: { additionalData: @use "@/style/element/index.scss" as *;, } } }, } ENV = 'production' VITE_PUBLIC_PATH = '/devOnlineStatus/' VITE_CLI_PORT = 8080 VITE_SERVER_PORT = 8888 VITE_BASE_API = /api #下方修改为你的线上ip VITE_BASE_PATH = https://demo.gin-vue-admin.com # router 模式 VITE_APP_USE_HASH = true 请帮我修改以上代码,当build打包时,前端页面url新增VITE_PUBLIC_PATH前缀
最新发布
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值