scss 一个非常简单的Baseline SCSS mixin,用于在CSS中为项目提供可视化基线。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss 一个非常简单的Baseline SCSS mixin,用于在CSS中为项目提供可视化基线。相关的知识,希望对你有一定的参考价值。

#Sass Baseline Mixin

A very simple Baseline SCSS mixin for providing a visual baseline in your project, in CSS.

![An example of the baseline](http://cl.ly/image/2I2k3S2P0A0m/baseline-example.png)

##The Mixin

In the mixin it has two arguments, `$baseline-height` and `$baseline-color`. These are set to defaults in the mixin, but feel free to change it to any colour and line-height you like.

##Usage in projects

When using the mixin, you may want to set a condition for showing the grid, such as this:

```
// style.scss
$show-baseline: true!default; //Set to false when not in use.

body {
	//...add your body styles here

	@if $show-baseline == true {
		// Include the baseline mixin
		@include baseline;
	}
}
```

And then you should have a suitable baseline for your project! Have fun!

[@iainspad](https://twitter.com/iainspad)
// Set up line-height and colour defaults for this mixin.
$line-height: 20px!default;
$line-color: #94d4ff!default;

/**
*
* Baseline Mixin
* Handy dandy mixin to provide a baseline for your typography.
*
* The mixin carries two arguments — the $baseline, which should match your line-height, and $baseline-color, the colour you want the lines to be.
* When using the mixin, you can change to the line-height and colour to what you desire.
*
* You can use this in your design to help with your typography, or you can use it as part of your design.
*
* Have fun!
*
**/
@mixin baseline($baseline: $line-height, $baseline-color: $line-color) {

	// Background Image property with  repeating gradients to provide the lines.
	background-image: -webkit-repeating-linear-gradient(180deg, transparent, transparent ($baseline - 1), $baseline-color ($baseline - 1), $baseline-color $baseline);
	background-image: -moz-repeating-linear-gradient(180deg, transparent, transparent ($baseline - 1), $baseline-color ($baseline - 1), $baseline-color $baseline);
	background-image: repeating-linear-gradient(180deg, transparent, transparent ($baseline - 1), $baseline-color ($baseline - 1), $baseline-color $baseline);

	// Background Sizing to contstrain the size of the gradient to the desired height.
	-webkit-background-size: 1px $baseline;
	background-size: 1px $baseline;
}

以上是关于scss 一个非常简单的Baseline SCSS mixin,用于在CSS中为项目提供可视化基线。的主要内容,如果未能解决你的问题,请参考以下文章

通过 Rollup 在 Vue SFC 中使用 SCSS 别名

scss scss中的简单条形图

scss 我简单的SCSS Cheatsheet

如何将scss转换成css文件

scss 动画小说看到Animate.css的一些非常酷的东西。

如何使用 Hugo 设置 SCSS