Installations
npm install flex-gap-polyfill
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8.0.0
Node Version
22.5.1
NPM Version
10.8.2
Score
76.2
Supply Chain
100
Quality
77.6
Maintenance
100
Vulnerability
99.3
License
Releases
Contributors
Unable to fetch Contributors
Languages
CSS (54.14%)
JavaScript (45.86%)
Developer
Download Statistics
Total Downloads
277,088
Last Day
518
Last Week
1,955
Last Month
7,992
Last Year
102,295
GitHub Statistics
149 Stars
370 Commits
6 Forks
1 Watching
32 Branches
6 Contributors
Bundle Size
24.93 kB
Minified
8.16 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.0.0
Package Id
flex-gap-polyfill@5.0.0
Unpacked Size
127.14 kB
Size
28.58 kB
File Count
7
NPM Version
10.8.2
Node Version
22.5.1
Publised On
01 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
277,088
Last day
2.8%
518
Compared to previous day
Last week
-7.2%
1,955
Compared to previous week
Last month
-14.2%
7,992
Compared to previous month
Last year
44.4%
102,295
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
1
Flex Gap Polyfill
This is a pure CSS polyfill using PostCSS to emulate flex gap using margins.
Known limitations
- Must use a wrapper div when using
margin: auto
orbackground
. - Percentage gaps aren't reliable if the container is not full width of parent container
- Width of flex items with percentages vary slightly from spec because of negative margin on container.
View the demo page for various test cases of the polyfill in action.
Example
1.container { 2 display: flex; 3 gap: 40px; 4}
Becomes:
1/* Output simplified for purpose of example */ 2 3.container > * { 4 --fgp-parent-gap-row: 40px; 5 --fgp-parent-gap-column: 40px; 6 --fgp-margin-top: calc(var(--fgp-gap-row) + var(--orig-margin-top, 0px)); 7 --fgp-margin-left: calc( 8 var(--fgp-gap-column) + var(--orig-margin-left, 0px) 9 ); 10 margin-top: var(--fgp-margin-top); 11 margin-left: var(--fgp-margin-left); 12} 13 14.container { 15 --fgp-gap: var(--has-fgp, 40px); 16 --fgp-gap-row: 40px; 17 --fgp-gap-column: 40px; 18 --fgp-margin-top: calc( 19 var(--fgp-parent-gap-row, 0px) - var(--fgp-gap-row) + var(--orig-margin-top, 0px) 20 ); 21 --fgp-margin-left: calc( 22 var(--fgp-parent-gap-column, 0px) - var(--fgp-gap-column) + var(--orig-margin-left, 0px) 23 ); 24 display: flex; 25 gap: var(--fgp-gap, 0px); 26 margin-top: var(--fgp-margin-top, var(--orig-margin-top)); 27 margin-left: var(--fgp-margin-left, var(--orig-margin-left)); 28}
The polyfill emulates flex gap by adding margins to each child element and applying a negative margin to the container.
- NEW Now works regardless of whether
display: flex
andgap
are used in the same rule (see Options for ways to optimise) - Works with unlimited nested elements with any combination of units, px > px, px > %, % > %, etc
- No additional class names or divs needed (except when using
margin: auto
orbackground
) - Works even when margin already exists on element (inline styles not supported)
- Style margin, borders and padding as normal
- Supports
gap
,row-gap
andcolumn-gap
Browser support
Supports all current modern browsers, Edge, Firefox, Chrome, Safari, Opera (any browser that supports calc()
and var()
).
Usage
Add Flex Gap Polyfill to your project:
1npm install flex-gap-polyfill postcss --save-dev
Use Flex Gap Polyfill to process your CSS:
1const flexGapPolyfill = require("flex-gap-polyfill"); 2 3flexGapPolyfill.process(YOUR_CSS /*, processOptions, pluginOptions */);
Or use it as a PostCSS plugin:
1const postcss = require("postcss"); 2const flexGapPolyfill = require("flex-gap-polyfill"); 3 4postcss([flexGapPolyfill(/* pluginOptions */)]).process( 5 YOUR_CSS /*, processOptions */ 6);
Options
-
only
Type: Array Default: undefined
When
true
polyfill will only apply whendisplay: flex | inline-flex
andgap
are used in the same rule. Provide an array of selectors to match additional rules. Can bestrings
orregexes
. Inlcude/* apply fgp */
within a rule to manually apply the polyfill. -
flexGapNotSupported
Type: String Default: false
Manually specify a selector to use when flex gap is not supported by detection via JavaScript, eg
flexGapNotSupported: '.flex-gap-not-supported'
.
-
webComponents
Type: Boolean Default: false
When
true
polyfill will also target slotted elements
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: Creative Commons Zero v1.0 Universal: LICENSE.md:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Reason
84 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-g77x-44xx-532m
- Warn: Project is vulnerable to: GHSA-gp8f-8m3g-qvj9
- Warn: Project is vulnerable to: GHSA-7gfc-8cq8-jh5f
- Warn: Project is vulnerable to: GHSA-7m27-7ghc-44w9
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-q8pj-2vqx-8ggc
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-vf6r-87q4-2vjf
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653
- Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj
- Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67
- Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-vxf5-wxwp-m7g9
- Warn: Project is vulnerable to: GHSA-9gr3-7897-pp7m
- Warn: Project is vulnerable to: GHSA-25mp-g6fv-mqxx
- Warn: Project is vulnerable to: GHSA-fmvm-x8mv-47mj
- Warn: Project is vulnerable to: GHSA-c59h-r6p8-q9wc
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-mpwj-fcr6-x34c
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More