Chandu yadav has Published 1091 Articles

How to choose between `window.URL.createObjectURL()` and `window.webkitURL.createObjectURL()` based on browser?

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 07:46:32

700 Views

To choose, you need to define a wrapper function −function display ( file ) {    if ( window.webkitURL ) {       return window.webkitURL.createObjectURL( file );    } else if ( window.URL && window.URL.createObjectURL ) {       return window.URL.display( file );    } else {    return null;    } }After that set it for cross-browser −var url = display( file );

How to save and restore the HTML5 Canvas states?

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 07:37:05

856 Views

HTML5 canvas provides two important methods to save and restore the canvas states.Canvas states are stored on a stack every time the save method is called, and the last saved state is returned from the stack every time the restore method is called.Sr.No.Method and Description1save()This method pushes the current state ... Read More

Perform Animation on CSS font-weight property

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 07:24:53

502 Views

To implement animation on font-weight property with CSS, you can try to run the following codeExampleLive Demo                    p {             border: 2px solid black;             width: 400px;             height: 100px;             animation: myanim 5s infinite;          }          @keyframes myanim {             70% {                font-weight: bold;             }          }                     This is demo text    

CSS flex item properties

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 07:08:45

311 Views

The following are the flex-item propertiesorderflex-growflex-shrinkflex-basisflexalign-selfLet us see an example of flex-basis propertySet the length of a flex item with the flex-basis CSS property. You can try to run the following code to implement the flex-basis propertyExampleLive Demo                    .mycontainer ... Read More

Align HTML5 SVG to the center of the screen

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 07:07:41

3K+ Views

SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.ExampleLet us see an example of SVG −                    #svgelem {   ... Read More

CSS Grid Columns

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 06:57:52

189 Views

The vertical line in the following is called Grid Columns.

Use CSS width property for a responsive video player

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 06:12:23

213 Views

To make your video player responsive, use the width property and set it to 100%ExampleLive Demo                                 video {                width: 100%;                height: auto;             }                                                         To check the effect, you need to resize the browser.    

HTML5 display as image rather than “choose file” button

Chandu yadav

Chandu yadav

Updated on 25-Jun-2020 05:31:47

377 Views

Use the JavaScript FileReader to allow users to choose an image.Let us see an example −         Here is the JS −function readURL(input) {    if (input.files && input.files[0]) {       var r = new FileReader();       r.onload = function (ev) {          $('#myid).attr('src', ev.target.result);       }       reader.readAsDataURL(input.files[0]);    } }   

CSS shorthand property for the flex-grow, flex-shrink, and the flex-basis properties

Chandu yadav

Chandu yadav

Updated on 24-Jun-2020 15:39:24

183 Views

Use the flex property to add flex-grow, flex-shrink and flex-basis properties in a single line.You can try to run the following code to implement the flex propertyExampleLive Demo                    .mycontainer {             display: flex;     ... Read More

How to reload the current page without losing any form data with HTML?

Chandu yadav

Chandu yadav

Updated on 24-Jun-2020 14:22:10

8K+ Views

The easiest way to reload the current page without losing form data, use WebStorage where you have -persistent storage (localStorage) or session-based (sessionStorage) which remains in memory until your web browser is closed.Try this when the page is about to reload, window.onbeforeunload = function() {    localStorage.setItem(name, $('#inputName').val());    localStorage.setItem(phone, ... Read More

Advertisements