Simple Sass Mixin for Width and Height

Developer
Size
4,523 Kb
Views
26,312

How do I make an simple sass mixin for width and height?

DRY typing the same values for width and height. Instead of typing width:200px; height:200px;, just type @include wh(150px);. What is a simple sass mixin for width and height? How do you make a simple sass mixin for width and height? This script and codes were developed by Ricardo Zea on 28 September 2022, Wednesday.

Simple Sass Mixin for Width and Height Previews

Simple Sass Mixin for Width and Height - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Sass Mixin for Width and Height </title> <link rel='stylesheet prefetch' href='css/https___s3_us_west_2_amaz.css'> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ @import "compass/css3";
@mixin size($width, $height: $width) { width: $width; height: $height;
}
.square { @include size(200px); }
/*=======================================*/
/*Styling stuff - Not needed for demo*/
h1 { }
h2 { margin-bottom:10px; }
h2:first-of-type { margin-top:0; }
.components-demo { display:flex; align-items:start; justify-content:space-around; width:60%; margin:auto; }
pre { margin: 0; }
.code { text-align: left; }
.square { background:linear-gradient($g, darken($g,10%)); border-radius:3px; box-shadow:inset 0 0 0 10px rgba(black,.05), 0 2px 5px rgba(black,.5); }
time { font-size: 11px; color:rgba(white,.1); }
.new-window { position: relative; padding-right: 16px; &:after { content:''; display: block; width: 14px; height: 12px; position: absolute; top: 10%; right: 0; background: url(https://i.stack.imgur.com/3H2PQ.png) no-repeat; }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1>Sass mixin for same Width and Height</h1>
<p>Instead of typing <code>width:200px; height:200px;</code> just type <code>@include size(200px);</code> or <code>@include size(20px,35px);</code></p>
<hr>
<h1>Demo</h1>
<div class="components-demo"> <div class="square"></div> <div class="code"> <h2>Mixin:</h2> <pre>@mixin size($width, $height: $width) { width: $width; height: $height;
}</pre> <h2>HTML:</h2> <code> &lt;div class="square">&lt;/div> </code> <h2>Usage:</h2> <code>.square { @include size(200px); }</code> <h2>Compiles to:</h2> <pre>.square { width: 200px; height: 200px;
} </pre> </div>
</div>
<hr>
<p>Created by <a href="http://ricardozea.me/" target="_blank">Ricardo Zea</a></p>
<time datetime="3-23-2014">Created on: March 23, 2014</time> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Simple Sass Mixin for Width and Height - Script Codes CSS Codes

@import "compass/css3";
@mixin size($width, $height: $width) { width: $width; height: $height;
}
.square { @include size(200px); }
/*=======================================*/
/*Styling stuff - Not needed for demo*/
h1 { }
h2 { margin-bottom:10px; }
h2:first-of-type { margin-top:0; }
.components-demo { display:flex; align-items:start; justify-content:space-around; width:60%; margin:auto; }
pre { margin: 0; }
.code { text-align: left; }
.square { background:linear-gradient($g, darken($g,10%)); border-radius:3px; box-shadow:inset 0 0 0 10px rgba(black,.05), 0 2px 5px rgba(black,.5); }
time { font-size: 11px; color:rgba(white,.1); }
.new-window { position: relative; padding-right: 16px; &:after { content:''; display: block; width: 14px; height: 12px; position: absolute; top: 10%; right: 0; background: url(https://i.stack.imgur.com/3H2PQ.png) no-repeat; }
}

Simple Sass Mixin for Width and Height - Script Codes JS Codes

//Add a title to the links that open in a new tab/window
$("a[target='_blank']").attr({title:'Opens in a new tab/window'}).addClass('new-window');
Simple Sass Mixin for Width and Height - Script Codes
Simple Sass Mixin for Width and Height - Script Codes
Home Page Home
Developer Ricardo Zea
Username ricardozea
Uploaded September 28, 2022
Rating 3.5
Size 4,523 Kb
Views 26,312
Do you need developer help for Simple Sass Mixin for Width and Height?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ricardo Zea (ricardozea) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!