which should I use (for python-based sites)? sass, compass, switchcss…alternatives? [closed]

蹲街弑〆低调 提交于 2019-12-07 03:38:57

问题


What is the best system to use to organize your css?

I am making several websites where I use python for back-end scripts. I'm interested in using something to help me organize LONG css scripts.

I'm curious about what python/django developers use, and have heard of switchcss. I've seen friends use sass/compass in the past, but this seems to require a ruby interpreter, and it might be good to build the sites in such a way that it would not require both python and ruby interpreters on the server (or my local machine). But if something like sass is definitively the best option, installing ruby is not difficult.


回答1:


I was asking myself the same question a few days ago. After extensive research:

"There is no best system to organize CSS"

I don't have much experience with LESS though SASS made more sense to me.

You don't need Ruby on the server for SASS just install it on your computer and upload/sync the outputted css files to your server as a normal css file. (SASS can support huge websites, a normal(minified)static css file = less work on the server).

The SASS website mentions that "SASS" syntax is more concise than the newer "SCSS" syntax. Many will argue but the indents are beautiful, no brackets & no semicolons as well as import as + & mixins as = etc. The SCSS syntax was simply created to compete with the LESS syntax. I've tried both and "to me" the SASS syntax is way more fun but that's just my POV.

The text editor & its settings you use plays a huge difference when choosing between SASS & the SCSS Syntax. If you don't know how to indent 2 spaces via a shortcut you may spend the entire time screwing your face up at the SASS syntax-ed code. SCSS won't give you errors for indenting out of place, you can be as messy as you need to be (just like hand css) really down to personal choice though Chris Eppstein made sense when thinking about personal & team work convenience (in comments):

http://thesassway.com/articles/sass-vs-scss-which-syntax-is-better

SCSS has populated fast, as it's default now, so if you're going to learn the SASS syntax you will probably end up knowing both since all the new resources are directed at SCSS. (BTW you can convert SASS syntax to SCSS vice versa)

So it's down to preference. Try them all including LESS. (Compass is excellent)




回答2:


Have you looked into LESS? I tried going the Sass/Scss route myself, but the Python ports of the Ruby original seemed not to measure up to their progenitor.

LESS is javascript, its client-side version does not rely on Node.js (as Stylus does) and it has an extremely intuitive syntax (though I'm not sure why the arroba was chosen for variable declaration).

On the client-side (there's a server-side option as well), you just include a reference to the code in the head using a standard script element:

<script src="js/less.js" type="text/javascript"></script>

and then, instead of using rel="stylesheet/css you use rel="stylesheet/less" for the external stylesheet link.




回答3:


Try CSS-On-Diet. It's written in Python and you can install it from PYPI:

pip install CSSOnDiet


来源:https://stackoverflow.com/questions/9951813/which-should-i-use-for-python-based-sites-sass-compass-switchcss-alternat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!