Found 10483 Articles for Web Development

How to capture HTML Canvas as gif/jpg/png/pdf with JavaScript?

AmitDiwan
Updated on 06-Dec-2022 11:18:06

3K+ Views

We can Use the canvas.toDataURL() to capture HTML canvas as different file formats, such as gif, png, jpg, webp, etc. Capture HTML Canvas as png Example Herein, after using canvas.DataURL(), set the type to image/png to allow saving the image as PNG − window.onload = function() { var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.fillStyle ... Read More

How to add images in select list in HTML?

AmitDiwan
Updated on 06-Dec-2022 11:07:47

13K+ Views

To add images in the select list, set the img text for the image in the tag, which is enclosed in a div − Python In the above div dropText, all the other select items is placed with the individual images. The dropText div is styled as. This also sets the background color of the select items i.e. skyblue − .dropText { display: none; position: absolute; background-color: skyblue; ... Read More

HTML table with 100% width, with vertical scroll inside tbody

AmitDiwan
Updated on 06-Dec-2022 10:58:10

10K+ Views

We will set the vertical scroll using the overflow-y property − overflow-y: auto; We will hide the horizontal scroll using the overflow-x property − overflow-x: hidden; Example Let us see an example − Display table with vertical scrollbar table.scrolldown { width: 100%; border-spacing: 0; ... Read More

How to Auto-Resize an Image to Fit a div Container using CSS?

AmitDiwan
Updated on 17-Feb-2025 13:01:55

3K+ Views

To auto resize an image to fit a div container, it ensures that the image is scaled properly without affecting its original aspect ratio. It helps in preventing the distortion of image and ensures that image fills the container without stretching or cropping. In this article we are having a div container and an image. Our task is to auto-resize image to fit the div container using CSS. Approaches to Auto Resize an Image to Fit div Container Here is a list of approaches to auto-resize an image to fit the div container using CSS which we will be discussing ... Read More

Why doesn't the height of a container element increase if it contains floated elements?

AmitDiwan
Updated on 06-Dec-2022 10:34:58

134 Views

To fix this use, we need to use the overflow property and set it on the outer parent div. We have an inner child div and an outer parent div − The outer parent div is set with the following CSS style. The min-height is set 100px and the overflow property is set to auto. This doesn’t let the height of the container element to increase even if it contains floated elements − .outer { margin: 0 auto; width: 960px; ... Read More

Does ID have to be unique in the whole HTML page?

AmitDiwan
Updated on 06-Dec-2022 10:31:37

195 Views

Yes, IDs must be unique in the entire HTML page. Even the official HTML standards suggest the same − Unique IDs with the id attribute Example Let us see an example. Here, we have used the id attribute − #myHeader { border: 2px solid yellow; background-color: orange; padding: 50px; text-align: ... Read More

How to Clear the Canvas for Redrawing?

AmitDiwan
Updated on 21-Nov-2023 20:56:07

1K+ Views

To clear the canvas for redrawing, use the canvas.clearRect() method in HTML. It clears the specified pixels. The parameters of the method includes − x − The x-coordinate to clear y − The y-coordinate to clear width − The width of the rectangle to clear height − The height of the rectangle to clear Let us see an example to create a canvas and clear it on the click of a button for redrawing in JavaScript. Here’s our canvas code that creates a canvas − var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.strokeRect(5, 5, 25, 15); ctx.scale(2, ... Read More

How to Close Browser Tabs With a Keyboard Shortcut?

AmitDiwan
Updated on 06-Dec-2022 10:32:40

4K+ Views

To close browser tabs, we can surely use Keyboard Shortcuts. Close a Tab on Google Chrome To close a tab on the Chrome web browser, use the following shortcut key on Windows − Ctrl+W To close the entire window on the Chrome web browser, use the following shortcut key on Windows − Ctrl+Shift+W Use the following shortcut key on Mac to close a tab on Chrome − Command+W To close the entire Firefox window on Mac, use the following shortcut − Command+Shift+W Close a Tab on Firefox To close a tab on the Firefox web browser, ... Read More

Create A Form Using HTML Tables?

AmitDiwan
Updated on 06-Dec-2022 10:16:51

9K+ Views

We can easily create a form with tables in HTML. But, before that let us see how to create a form in HTML. Create a Form in HTML Example We will first see how to create a form in HTML using only the tag − HTML Form Details Select the subject you want to choose: Programming Web Development Database Submit Output Create a Form using HTML Tables Example Now, let us convert the above form to a form created using HTML tables − HTML Form Details Select the subject you want to choose: Programming Web Development Database Submit Output

Why doesn't height: 100% work to expand divs to the screen height?

AmitDiwan
Updated on 06-Dec-2022 10:15:28

218 Views

To set the height to 100% for expanding divs to the screen height, set the entire document to − html { height: 100%; } First, we have set both the html and body to − html, body { height: 100%; } The div is set with height and min-height property − #mydiv { min-height: 100% !important; height: 100%; border: 2px solid yellow; width: 200px; background: orange; } Under the , we have our div for which we set the CSS property above − Demo Text Example Let us now see the complete example − Example html, body { height: 100%; } #mydiv { min-height: 100% !important; height: 100%; border: 2px solid yellow; width: 200px; background: orange; } Demo Text Output

Advertisements