Responsive web design has become the new normal, and many designers, developers and organizations have realized that static sample scripts are no longer an effective way to show their website to customers. As Stephen Hay said:
"We designed not pages, but component systems."
As the viewport changes and layout is adjusted, these components are rearranged and resized in various container sizes. Many designers turn to “style tile” to help customers understand and approve design directions without having to build fully detailed sample drafts instead of spending weeks building 3-4 static sample drafts of different screen sizes for a single website design (and take it out) the risk of clients rejecting all jobs). Style tile is designed to "display interface selections to customers without investing in multiple Photoshop models". Sometimes they are called element collages or UI maps.
The rise of style guides is very consistent with another latest development in front-end development: start in-browser prototype design as early as possible. When we integrate style guides to help customers understand design and move the process from design software to tagging, we end up creating a live web version of the PDF brand guide documents that many customers use.
As the title of this post suggests, Sass has some features that make it easier for us to create dynamic style guides. Let's take a look at these features now.
Color palette
One way to make style guides easier is to automate repeatable information. For example, to show your color palette to your customers, you can create several squares, each showing one color. Your HTML might look like this:
<ul class="color-palette"> <li class="color-blue"><span class="swatch">Blue</span></li> <li class="color-red"><span class="swatch">Red</span></li> <li class="color-green"><span class="swatch">Green</span></li> <li class="color-gray"><span class="swatch">Gray</span></li> <li class="color-dark-gray"><span class="swatch">Dark Gray</span></li> </ul>
This may not be an ideal mark (you can absolutely use ::before
instead of span.swatch
), but it works for this demo.
After this is done, you need CSS to layout these color samples for your customers. We can use Sass to make it easier. Sass mapping is an excellent way to store these color values:
$colors: ( blue: #2980b9, red: #e74c3c, green: #27ae60, gray: #95a5a6, dark-gray: #2c3e50 );
By storing these values ??in the map (rather than as 5 or more variables), we are now able to iterate over them and generate CSS automatically.
// 只需一點(diǎn)布局樣式即可制作方形樣本 ul { margin: 0; padding: 0; text-align: center; } li { display: inline-block; width: 15%; margin: 1%; padding: .5em; box-shadow: 0 1px 4px -1px rgba(0,0,0,.5); } .swatch { display: block; height: 0; margin-bottom: .5em; padding: 100% 0 0; } // 現(xiàn)在,為每個(gè) .swatch 分配正確的 background-color @each $name, $value in $colors { .color-#{$name} { .swatch { background-color: $value; } } }
Title
You can also use mappings for title styles. The following example is a little more complicated than color mapping.
$sans: Open Sans, Tahoma, sans-serif; $serif: Droid Serif, Palatino, serif; $headings: ( h1: bold 2em/1.2 $sans, h2: light 1.5em/1.2 $sans, h3: bold 1.2em/1.2 $sans, h4: bold 1em/1.2 $sans, h5: bold 1em/1.2 $serif, h6: italic 1em/1.2 $serif ); @each $element, $font-property in $headings { #{$element} { font: $font-property; } }
If you get more complicated with title styles, that's fine. If you plan to add properties such as color, letter spacing, or text conversion, you need to use nested mappings as shown in the following example:
$headings-complex: ( h1: ( font: bold 2em/1.2 $sans, color: map-get($colors, blue) ), h2: ( font: 200 1.5em/1.2 $sans, letter-spacing: .1em, text-transform: uppercase, color: map-get($colors, dark-gray) ), h3: ( font: bold 1.2em/1.2 $sans, color: map-get($colors, dark-gray) ), h4: ( font: normal 1em/1.2 $sans, letter-spacing: .1em, text-transform: uppercase, color: map-get($colors, dark-gray) ), h5: ( font: bold 1em/1.2 $serif, color: map-get($colors, blue) ), h6: ( font: italic 1em/1.2 $serif, color: map-get($colors, dark-gray) ) ); @each $element, $style-map in $headings-complex { #{$element} { @each $property, $value in $style-map { #{$property}: $value; } } }
At this point, you might ask, "Why not write all the nested mapped data directly in CSS? It looks like CSS, and I didn't really save much time by looping it." Make things happen with Sass The advantage of getting it easier is that if a technology does not make it easier for you, don't use it. However, if that complex mapping works for your project, use it! Back to the simpler usage of Sass mapping, the button is another good opportunity to automate style tiles: This code snippet will create the CSS of the button based on the same color as the palette above. If you have a different UI button color set, you can use different mappings for The following is all the code in this article on CodePen: The above tip helps us by writing some duplicate CSS for us, but requires us to write our own HTML to match that CSS. There are also some great tools to generate the markers you need. I won't explain these tools in detail, but you can check out their examples and documentation. StyleDocco is an npm module that takes Markdown written in CSS comment blocks and generates matching HTML. Hologram is a Ruby gem that also uses Markdown in CSS comment blocks to create style guide markup. Style tile is a great way to show your client the design vision without unexpectedly convinced them that they are getting a fixed-sized, pixel-perfect website. They help customers understand the fluency of their website while still conveying the nature of visual design. Sass makes it easier for us to generate these style tiles using tools such as mapping and looping. Do you use Sass to make style tile or prototyping easier? Please let us know in the comments! The above is the detailed content of Style Tiles with Sass. For more information, please follow other related articles on the PHP Chinese website!Button
<ul class="color-palette">
<li class="color-blue"><span class="swatch">Blue</span></li>
<li class="color-red"><span class="swatch">Red</span></li>
<li class="color-green"><span class="swatch">Green</span></li>
<li class="color-gray"><span class="swatch">Gray</span></li>
<li class="color-dark-gray"><span class="swatch">Dark Gray</span></li>
</ul>
$button-colors
. Style Guide Generator
Conclusion

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

There are three ways to create a CSS loading rotator: 1. Use the basic rotator of borders to achieve simple animation through HTML and CSS; 2. Use a custom rotator of multiple points to achieve the jump effect through different delay times; 3. Add a rotator in the button and switch classes through JavaScript to display the loading status. Each approach emphasizes the importance of design details such as color, size, accessibility and performance optimization to enhance the user experience.

To deal with CSS browser compatibility and prefix issues, you need to understand the differences in browser support and use vendor prefixes reasonably. 1. Understand common problems such as Flexbox and Grid support, position:sticky invalid, and animation performance is different; 2. Check CanIuse confirmation feature support status; 3. Correctly use -webkit-, -moz-, -ms-, -o- and other manufacturer prefixes; 4. It is recommended to use Autoprefixer to automatically add prefixes; 5. Install PostCSS and configure browserslist to specify the target browser; 6. Automatically handle compatibility during construction; 7. Modernizr detection features can be used for old projects; 8. No need to pursue consistency of all browsers,

Themaindifferencesbetweendisplay:inline,block,andinline-blockinHTML/CSSarelayoutbehavior,spaceusage,andstylingcontrol.1.Inlineelementsflowwithtext,don’tstartonnewlines,ignorewidth/height,andonlyapplyhorizontalpadding/margins—idealforinlinetextstyling

Setting the style of links you have visited can improve the user experience, especially in content-intensive websites to help users navigate better. 1. Use CSS's: visited pseudo-class to define the style of the visited link, such as color changes; 2. Note that the browser only allows modification of some attributes due to privacy restrictions; 3. The color selection should be coordinated with the overall style to avoid abruptness; 4. The mobile terminal may not display this effect, and it is recommended to combine it with other visual prompts such as icon auxiliary logos.

Use the clip-path attribute of CSS to crop elements into custom shapes, such as triangles, circular notches, polygons, etc., without relying on pictures or SVGs. Its advantages include: 1. Supports a variety of basic shapes such as circle, ellipse, polygon, etc.; 2. Responsive adjustment and adaptable to mobile terminals; 3. Easy to animation, and can be combined with hover or JavaScript to achieve dynamic effects; 4. It does not affect the layout flow, and only crops the display area. Common usages are such as circular clip-path:circle (50pxatcenter) and triangle clip-path:polygon (50%0%, 100 0%, 0 0%). Notice

TheCSSPaintingAPIenablesdynamicimagegenerationinCSSusingJavaScript.1.DeveloperscreateaPaintWorkletclasswithapaint()method.2.TheyregisteritviaregisterPaint().3.ThecustompaintfunctionisthenusedinCSSpropertieslikebackground-image.Thisallowsfordynamicvis

To create responsive images using CSS, it can be mainly achieved through the following methods: 1. Use max-width:100% and height:auto to allow the image to adapt to the container width while maintaining the proportion; 2. Use HTML's srcset and sizes attributes to intelligently load the image sources adapted to different screens; 3. Use object-fit and object-position to control image cropping and focus display. Together, these methods ensure that the images are presented clearly and beautifully on different devices.

Different browsers have differences in CSS parsing, resulting in inconsistent display effects, mainly including the default style difference, box model calculation method, Flexbox and Grid layout support level, and inconsistent behavior of certain CSS attributes. 1. The default style processing is inconsistent. The solution is to use CSSReset or Normalize.css to unify the initial style; 2. The box model calculation method of the old version of IE is different. It is recommended to use box-sizing:border-box in a unified manner; 3. Flexbox and Grid perform differently in edge cases or in old versions. More tests and use Autoprefixer; 4. Some CSS attribute behaviors are inconsistent. CanIuse must be consulted and downgraded.
