Code Monkey home page Code Monkey logo

angled-edges's Introduction

Angled Edges 📐 Build Status Bower version npm version

A Sass mixin for creating angled edges on sections by dynamically encoding SVGs.

Need angled edges in regular CSS? Check out the Angled Edges Generator.

angled edge

Usage

Import partial:

@import "angled-edges";

This mixin has 3 required parameters: location, hypotenuse, fill

@include angled-edge($location, $hypotenuse, $fill);

The main mixin creates an svg right triangle that is encoded, set as a background image of a pseudo element, and absolutely positioned.

Examples

https://codepen.io/fusco/pen/mzymKm

Options

Parameter Description
$location Location of shape relative to parent element
  • inside top
  • outside top
  • inside bottom
  • outside bottom
$hypotenuse Side of the right triangle that the hypotenuse is on
  • upper left
  • upper right
  • lower left
  • lower right
$fill Fill color of triangle
$height Optional - Height of triangle - Accepts a unitless integer that is equivalent to height in px
$width Optional - Width of triangle - Accepts a unitless integer that is equivalent to width in px (If nothing is passed triangle will span to a 100% fluid width)

Upgrading from 1.x

Version 2 now defaults with a fluid width of 100%. Since this is the preferred value, width and height parameters have switched order with height now being first. This allows for easier usage where

@include angled-edge('outside bottom', 'lower right', 150);

now means a 150px tall with at a default of 100% width. If a fluid width is not needed, you can still pass in a unitless width like in 1.x. If you previously were using background-size to manipulate the shape, you will need to remove this property as the mixin also uses this to assist with making the shape full-width.

Demo

https://angled-edges.josephfus.co

Browser Support

Anywhere SVG is supported.

  • IE 9+
  • Edge
  • Firefox
  • Chrome
  • Safari
  • Opera
  • iOS Safari
  • Opera Mini
  • Android Browser
  • Chrome for Android

Project Ports

angled-edges's People

Contributors

josephfusco avatar kittygiraudel avatar omgmog avatar stowball avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angled-edges's Issues

Responsiveness

This isn't responsive to the view port size so it can overlap content on some screens. If you want to make the height of the angle reactive to the view port width or height just go into the angled-edges.scss file and use control-f to replace px with vw or vh
Not really an issue, just pointing it out for those who might not know.

Docs are not up to date with API

Recently working on a project that had this included but the mixin name as well as its params do not match up with the current documentation.

Documentation Examples

There are no pre-rendered, sass code examples, including on the demo page. In fact, when I try the one example in the readme, it triggers the coded exception. Bummin.

Why not clip-path ?

I am a beginner in css, and I was hurt by curiosity when I failed in your repository.

Why do you use SVG instead of the clip-path property ?

I think about something like this pen.

Cheers,

Support left/right edge

Hi,
Would it be possible to add left/right inside/outside edge support to build trapezoid shape ?
Isosceles-Trapezoids
Right-Trapezoids

FR: Masking Images

Incredibly useful plugin – would be nice to see it as a Tailwind plugin, but it's still easy enough to integrate in the build chain as scss. :)

Wondering – shouldn't it be possible to use this as an image mask, so that you didn't need to set the color to match different backgrounds, or create extra code in the case of supporting a website's dark mode?

iOS Spacing Bug

I'm getting a problem where on iOS the svg background is padded by around 15px.

I think this relates to a common svg bug with iOS, but most of the solutions seem to relate to svg image elements rather than svg backgrounds - the 1% hack, and declaring 100% width/height.

typical implementation for me is …

.banner-bottom-text {

	width: 100%;
	@include angled-edge(
			$location:'inside bottom',
			$hypotenuse: 'upper left',
			$fill: $col-brand-tertiary,
			$width: 1500,
			$height: 100
			);

			opacity: 0.7;	
		&::before {
			background-size: 100% 100%;
			}
}

Any ideas?

BTW Thanks for an amazing mixin and very much +1 on liquid dimensions please.

Space on the flat edge of the shape

First off, thanks for making this, it's brilliant!

I've just hit on a small problem though when testing a site on Android. I'm getting what looks like a 1px gap on the straight edge.

I've also just had a look at your demo site on Android, just to check to make sure it wasn't something I was doing and you can see the same thing happening on the first example. The odd thing is that if I pinch and zoom in and then out again the gap disapears.

Any ideas why this might be happening?

The demo doesn't show any angled edges on Firefox

I just tried to view the demo on Firefox (46, on linux) and nothing shows up, as the screenshot shows.

Inspect says "cannot load image" when you hover over the url, but that could just be a normal thing for data urls.

screenshot-angled-edges josephfus co 2016-06-16 10-52-39

Transparent angles?

Hi,

is there a way to set a transparancy for the angles? If i use for example rgba(0,166,141,.8) nothing happens.

sub-pixel rounding issues with chrome zoom levels

Hello - Thanks for your awesome script! I noticed a subpixel rounding issue with chrome zoom levels (not with your code) where it looks like there is a border where the svg overlaps a div above or below the one where your svg object is attached. This is simply fixed by adding a 1px border to the div that your svg is attached to with the same background color as the svg object. This is not an issue with your code, but I wanted to help others if they are struggling w/ this chrome issue!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.