Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

background-cover

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

background-cover

Simulate 'background-size: cover' on HTMLVideoElement and HTMLImageElement.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

background-cover

Simulate 'background-size: cover' on HTMLVideoElement and HTMLImageElement.

Syntax

BackgroundCover(element, container [, horizontalAlign, verticalAlign]);
  • element: HTMLVideoElement, or HTMLImageElement, or other dom element (e.g. HTMLCanvasElement)
  • horizontalAlign: Number from 0 to 1, where 0 means aligned to the left. Default value is 0.5 (centered);
  • verticalAlign: Number from 0 to 1, where 0 means aligned to the top. Default value is 0.5 (centered);

Example


var BackgroundCover = require('background-cover');

var videoContainer = document.getElementById('video-container');
var video = document.getElementById('video');

video.addEventListener('loadedmetadata', function() {
  BackgroundCover(video, videoContainer);
);

Check out tests for more examples.

Install

npm install background-cover --save

Tests

npm run test-video
npm run test-image

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Package last updated on 09 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc