Draw A Diagonal Line Through A Box - jQuery diagonal.js

File Size: 14.2 KB
Views Total: 2933
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Draw A Diagonal Line Through A Box - jQuery diagonal.js

diagonal.js is a minimal jQuery plugin to draw a responsive diagonal line through a container element that automatically adapts to the width of the container on window resize.

How to use it:

1. Create a container where you want to draw the diagonal line.

<div class="box"></div>
  margin:50px auto;
  border:1px solid #333;

2. Insert the jquery.diagonal.js after jQuery library.

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" 
<script src="src/jquery.diagonal.js"></script>

3. Get the degree of the diagonal.

var deg = $.diagonal.deg(".box");

4. Draw the the diagonal line inside the container and specify the color as per your needs.

  deg: deg,
  color: '#fff'

5. Decide whether to adapt to the width of the container.

  deg: deg,
  color: '#fff',
  isrwd: true

This awesome jQuery plugin is developed by fdjkgh580. For more Advanced Usages, please check the demo page or visit the official website.