设计 · 最新文章

今日新增 38 篇 · 共 831 篇 · 来自 20 个博客

Sara Soueidan··Sara Soueidan

Art-Directing SVG Images With The viewBox Attribute: How-To, Notes, Tips and Why We Need A viewBox Property in CSS

AI 摘要The article explains how SVG's viewBox attribute can be used to crop an SVG canvas and art-direct images, showing different portions of a composition at different screen sizes for responsive web design. It covers practical techniques such as retrieving crop coordinates from graphics editors like Adobe Illustrator, handling aspect-ratio mismatches with clipPath, and notes that changing the viewBox across media queries currently requires JavaScript. The author argues that a native viewBox property in CSS would make this process far more optimal and hopes the article serves as a use case to push that old SVGWG proposal forward.

Sara Soueidan··Sara Soueidan

An Introduction To Graphical Effects in CSS

AI 摘要This article provides an in-depth introduction to CSS graphical effects, specifically covering CSS Filters along with Compositing and Blending capabilities. It explains the properties for each feature, their different values, and includes usage examples. The article demonstrates the various graphical effects that can be created using only a few lines of CSS.

Sara Soueidan··Sara Soueidan

A Primer To Background Positioning In CSS

AI 摘要This article provides a deep dive into CSS's background positioning properties, illustrated with visual explanations and examples. It covers lesser-known features such as edge offset values, which allow a background image to be positioned relative to any edge—not just top and left—using a length value for the offset. The article aims to teach readers all about these capabilities and more.

Sara Soueidan··Sara Soueidan

Building a Circular Navigation with SVG

AI 摘要The article explains why SVG is better suited than CSS for building circular navigation menus, as SVG's semantic, interactive shape elements avoid the hacky transformations and browser inconsistencies of the CSS approach. It gives an overview of how to draw menu sectors using the SVG element, covering the line and arc commands, coordinate calculations with polar-to-cartesian conversion, and rotating the sectors with SVG's native transformations. It also briefly describes positioning icons within the sectors using and elements.

Sara Soueidan··Sara Soueidan

Extending the Color Cascade with the CSS currentColor Variable

AI 摘要This article explains the benefits of using variables in CSS style sheets, a practice familiar to those who use preprocessors like Sass or LESS. It provides an overview of why variables are so popular and useful, with a particular focus on introducing the currentColor variable.

Sara Soueidan··Sara Soueidan

Better SVG Fallback and Art Direction With The picture Element

AI 摘要The article explains how the HTML element offers a better, mostly JavaScript-free way to serve SVG foreground images with fallbacks for non-supporting browsers and to apply art direction by loading different images based on media queries, compared to the traditional approach that requires JavaScript solutions like Modernizr. It shows how to use the , , srcset, and sizes attributes to provide fallbacks at various resolutions and to serve smaller or cropped SVGs on smaller screens. Since browser support for is still incomplete, the author recommends the Picturefill polyfill, including a conditional-comment workaround for IE9.

Sara Soueidan··Sara Soueidan

Compositing And Blending In CSS

AI 摘要This article explains compositing and blending in CSS, introducing the concepts of source and destination elements, Porter Duff compositing operations, and how 16 available blend modes determine how overlapping colors interact. It covers two main properties: background-blend-mode, which blends an element's background layers with each other and its background color, and mix-blend-mode, which blends an element with content in its backdrop. The author describes each blend mode's effect and provides an interactive demo to help users experiment and pick the right mode, since results are often hard to predict.

Sara Soueidan··Sara Soueidan

Useful SVGO[ptimization] Tools

AI 摘要The article introduces SVGOMG, a new GUI for the SVGO SVG optimization tool built by Jake Archibald, which lets users select optimizations and see a live preview of the result, addressing SVGO's previous lack of preview and its risk of breaking animated or scripted SVGs. It also overviews other SVGO tools and plugins for different workflows, including Adobe Illustrator (SVG NOW), Inkscape, Sketch (SVGO Compressor), a drag-and-drop GUI, Grunt/Gulp plugins, and an OS X folder action, while noting precautions such as disabling the removeViewBox optimization and backing up files when originals are replaced.

Sara Soueidan··Sara Soueidan

Tips For Optimizing SVG Delivery For The Web

AI 摘要SVGs are a valuable asset in responsive web design, but like any image format, they must be properly optimized to avoid negatively impacting page performance. The article outlines several steps that developers can take to ensure they deliver well-optimized SVG resources for the web.

Sara Soueidan··Sara Soueidan

An Overview Of SVG Sprite Creation Techniques

AI 摘要This article, written for 24Ways, provides an overview of three techniques for creating SVG sprites as an icon system that can replace icon fonts. It also examines several available tools that can automate sprite creation and provide fallback support.

Sara Soueidan··Sara Soueidan

Styling and Animating SVGs with CSS

AI 摘要The article, written for Smashing Magazine, explains how CSS can be used to style and animate SVGs in much the same way as HTML elements. It is a modified transcript of a talk the author gave at CSSconf EU and From the Front, covering the prerequisites and techniques for working with CSS in SVG.

Sara Soueidan··Sara Soueidan

A Guide to SVG Animations (SMIL)

What the title says: a complete guide to SVG animations derived from the SMIl specification. The extensive guide features a lot of demos and goes over the animations syntax, covering almost everything you need to know to get started with SV

Sara Soueidan··Sara Soueidan

Making SVGs Responsive With CSS

An article on how to make embedded SVGs cross-browser responsive. We're going to cover embedding techniques, how to apply the "Padding Hack" and how to use inline media queries to make SVGs adaptive.

Sara Soueidan··Sara Soueidan

Understanding SVG Coordinate Systems and Transformations (Part 3) — Establishing New Viewports

AI 摘要This article, the third in a series on SVG coordinate systems and transformations, explains how to establish new viewports and user coordinate systems by nesting elements (or using elements like ). It demonstrates that nested SVGs, each with their own viewBox and preserveAspectRatio attributes, allow individual parts of a graphic to respond independently to viewport resizing, making elements flexible or fluid without distorting them. The concepts are illustrated through an example of a cracked egg graphic whose upper shell lifts to reveal a chicken as the screen shrinks.

Sara Soueidan··Sara Soueidan

Understanding SVG Coordinate Systems and Transformations (Part 2) — The transform Attribute

AI 摘要This article, the second in a series on SVG coordinate systems and transformations, explains the SVG transform attribute and its transformation functions—matrix, translate, scale, skewX/skewY, and rotate—including their syntaxes and how they differ from their CSS counterparts. It emphasizes that applying the transform attribute establishes a new user coordinate system (a copy of the current user space) on the element, so transformations affect the element's entire coordinate system and may reposition it within the viewport. While similar in many ways to CSS transformations on HTML elements, SVG transformations differ mainly in how and where the coordinate system is established and transformed.

Sara Soueidan··Sara Soueidan

Understanding SVG Coordinate Systems and Transformations (Part 1) — The viewport, viewBox, and preserveAspectRatio

AI 摘要This article, the first in a three-part series, explains the fundamentals of SVG coordinate systems and transformations, focusing on the viewport, viewBox, and preserveAspectRatio attributes. It clarifies that the SVG canvas is conceptually infinite while only the viewport region is visible, and shows how width and height establish the initial viewport coordinate system. The article also demonstrates how the viewBox attribute lets you define a custom user coordinate system that effectively crops and scales the graphic to fill the viewport, with preserveAspectRatio becoming relevant when the aspect ratios of the two systems differ.

Sara Soueidan··Sara Soueidan

Clipping in CSS and SVG — The clip-path Property and <clipPath> Element

AI 摘要This article is a comprehensive guide to clipping in CSS and SVG, explaining how the clip-path property and the SVG element can be used to hide parts of elements within custom non-rectangular shapes. It covers using basic shape functions (polygon(), circle(), ellipse(), inset()), referencing SVG clip paths including paths made from text or multiple shapes, and applying clipping to both HTML and SVG elements. It also explains how to specify a reference box for basic-shape clip paths and notes that browser support for these features was still limited at the time of writing.

Sara Soueidan··Sara Soueidan

Structuring, Grouping, and Referencing in SVG — The<g>, <use>, <defs> and <symbol> Elements

AI 摘要This article explains how SVG provides elements for structuring, grouping, and referencing graphics: the element logically groups related elements so styles, transformations, and interactivity can be applied to them collectively, while allows reusing existing elements similar to copy-paste. It also covers the element, which defines elements (like gradients, masks, or groups) without rendering them so they can serve as templates referenced later, addressing drawbacks of such as relative positioning and non-overridable styles. Throughout, the article highlights the differences, advantages, and use cases of each element with practical examples like grouping and reusing an SVG bird illustration.

Sara Soueidan··Sara Soueidan

Moving Forward With CSS Shapes

Following up with the CSS Shapes 101 article, I share a list of great resources to learn more about CSS Shapes, including tutorials, examples, and developer tools.