How to use mixin include and extend in scss
SASS provides two main ways to reuse styles — @extend and mixins — this article is a brief look into how both work and which to use. TLDR: @extend with/without placeholders are best when you have shared static, similar styles but they cause duplicate classes while mixins are best for dynamic styles which uses passed arguments but they lead to repeated declarations. @extend The extends syntax allows you to share styles between two selectors. It’s analogous to the way classes are combined in HTML. Using @extend , this can be written as: .h1-heading{ font-size:30px; } content{ @extend h1-heading; color:red; } Mixins Mixins are quite similar to extends, for example, using mixins, we could have done this: @mixin webfont() { font-family: webfont, sans-serif; font-weight: 700; } ... .foo { @include webfont(); } ... .bar { @include webfont(); } Generally, if you don’t have dynamic styles, using @extend (preferably using placeholders — unless you are referencing the class in the DOM) is good enough. Using mixins for static-only styles causes unnecessarily bloated stylesheets so it’s a good idea to keep the declarations minimal and only for dynamic declarations because it’s going to be duplicated.
via YouTube https://youtu.be/qOVIwvjfYcQ
The Coding Bus is an educational youtube channel for learning the Free programming languages online. Content includes tutorials and references relating to HTML, CSS, JavaScript, JSON, PHP, Python, AngularJS, React.js, SQL, Bootstrap, Sass, Node.js, jQuery, XQuery, AJAX, XML, Raspberry Pi, C++, and Java
Subscribe to:
Post Comments (Atom)
😍Developer on Weekends #shorts #officememes #developermemes
😍Developer on Weekends #shorts #officememes #developermemes Welcome to the latest viral YouTube shorts meme for developers! 😍Developer on...
-
How to create a free online course website with WordPress in 2019 In this video, I'm going to show you how to create an online course...
-
How to make a Piano App in MIT App Inventor 2 How to make a Piano App in MIT App Inventor 2 Download Code-: https://ift.tt/2VbH8Bu via You...
-
Privacy Policy Minzor built the 3d wallpapers app as a Free app. This SERVICE is provided by Minzor at no cost and is intended for use as is...
No comments:
Post a Comment