mituri

[scss] rounded mixin

Feb 13th, 2020
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. https://jsfiddle.net/ohz0fpu1/
  2.  
  3. scss:
  4.  
  5. @mixin rounded($amount: 10px, $position: null) {
  6. @if $position == null {
  7. border-radius: $amount;
  8. } @else {
  9. @if $position == "top" or $position == "bottom" {
  10. border-#{$position}-left-radius: $amount;
  11. border-#{$position}-right-radius: $amount;
  12.  
  13. } @else {
  14. border-#{$position}-radius: $amount;
  15. }
  16. }
  17. }
  18.  
  19. .a {
  20. width: 30px;
  21. height: 30px;
  22. background-color: pink;
  23. margin-bottom: 10px;
  24. }
  25.  
  26. .a1{
  27. @include rounded(); /*as default 10px on all corners*/
  28. }
  29. .a2{
  30. @include rounded(15px); /*all corners*/
  31. }
  32. .a3{
  33. @include rounded(15px, top); /*all top corners*/
  34. }
  35. .a4 {
  36. @include rounded(15px, bottom); /* all bottom corners*/
  37. }
  38. .a5{
  39. @include rounded(15px, top-right); /*this corner only*/
  40. }
  41. .a6 {
  42. @include rounded(15px, top-left); /*this corner only*/
  43. }
  44. .a7{
  45. @include rounded(15px, bottom-right); /*this corner only*/
  46. }
  47. .a8 {
  48. @include rounded(15px, bottom-left); /*this corner only*/
  49. }
  50.  
  51.  
  52. -----------------------------------------------
  53. html:
  54.  
  55. <div class="a a1"></div>
  56. <div class="a a2"></div>
  57. <div class="a a3"></div>
  58. <div class="a a4">a</div>
  59. <div class="a a5"></div>
  60. <div class="a a6"></div>
  61. <div class="a a7"></div>
  62. <div class="a a8"></div>
Advertisement
Add Comment
Please, Sign In to add comment