Tips for optimizing webcam image responsiveness: Although the webcam is functioning properly, it may not

Looking for help with making a responsive webcam image using webcam.js. I've defined the height and width in my JavaScript, but the captured image is not responsive.

Here's my JavaScript code:

function setwebcam()
{
  //$("#set_cam").hide();
  //$("#take_photo").show();
  Webcam.set({
    width: 320,
    height: 480,
    align:'center',
    image_format: 'jpeg',
    jpeg_quality: 100
  });
  Webcam.attach( '#my_camera' );        
}

function setcoord()
{    
  $('#cropbox').Jcrop({
    aspectRatio: 1,
    onSelect: updateCoords
  }); 
}

function updateCoords(c)
{
  $('#x').val(c.x);
  $('#y').val(c.y);
  $('#w').val(c.w);
  $('#h').val(c.h);
}

And here's my HTML code:

<div class="col-lg-12" id="cap_div" style="background-color:#f9f9f9; 
                                          box-shadow: 0 1px 4px #ccc;
                                          margin-bottom:95px;
                                          margin-top:20px;
                                          display:none;"   >
  <div class="row">
    <div class="col-sm-12">
      <div class="col-md-12"  id="my_camera">
      
      </div>    
    </div>
  </div>
  <h3 class="text-center" style="font-size:36px;  color:#000000;">
    Click on capture to get image
  </h3>
  
  <hr>
  <div class="row" style="z-index: 10; padding-bottom:  1em;">
    <p class="text-center">
      <a onClick="take_snapshot();" id="take_photo" class="browse_btn flat-button orange-flat-button btn btn-warning2 btn-lg" >
        <i class="fa fa-camera" aria-hidden="true"></i>
        Capture
      </a>
      <span class="visible-xs visible-sm"  id="oder" style="padding:10px 0;">
        - or -
      </span>
    </p>
  
      
  </div>
</div>

Any suggestions on how to make the webcam image responsive? The webcam itself works fine, but responsiveness is a challenge. Any help would be greatly appreciated.

Answer №1

One way to incorporate responsive design is by using CSS breakpoints.

@media (max-width: 576px) {
    #my_camera video {
        max-width: 80%;
        max-height: 80%;
    }

    #results img {
        max-width: 80%;
        max-height: 80%;

    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take to correct the color selection of a button that has been pressed down

Here is the code snippet that I am currently working with: HTTP: <label class="instructions" for="hidden_x"> Insert X: </label> <button type="button" class="button" name="button_x" value="1" id="x_1" onclick="document.getElementById(' ...

Apply a see-through overlay onto the YouTube player and prevent the use of the right-click function

.wrapper-noaction { position: absolute; margin-top: -558px; width: 100%; height: 100%; border: 1px solid red; } .video-stat { width: 94%; margin: 0 auto; } .player-control { background: rgba(0, 0, 0, 0.8); border: 1px ...

Retrieve the Span class value contained within a Select Option

I realize it may appear repetitive, but it is not. This is the appearance of my select: <select id="avpMy4Y7E4cH_-iIRmmAK6-2GsEOu6Sjr-0-0"> <option value="1Ltr [ <span class=money>Rs.1,495.00</span> ]">...< ...

Having trouble with displaying a Bootstrap modal in HTML and CSS?

I am new to programming and facing a challenge with my modal not displaying as expected. Instead of appearing in a popup, it is showing on the page itself. I really need help finding a solution for this issue. Any assistance would be highly appreciated. Be ...

"Problem encountered with retrieving Background Events in FullCalendar using JSON string generated from a PHP script

My goal is to incorporate a list of holidays as Background Events from an external event source called "holidays.php." However, I am encountering an issue in the month view where the background events for holidays are not displaying properly and causing ot ...

Choosing just the element that was clicked and added to the DOM

I've been experimenting with JQuery in a web app I'm developing. The app involves dynamically adding elements to the DOM, but I've encountered an issue with click events for these newly added elements. I'm looking for a way to target an ...

Ensuring that the header contains a centered element and a right-justified element, both aligned perfectly vertically

I'm currently working on creating a unique header design for my website, where I want one element to be centered and another element to be right-justified within the header. After brainstorming different approaches, I came up with the following metho ...

What is the rationale behind transmitting JSON data within HTML in Next.js's static site generation (

When a webpage is loading, the entire HTML document is sent, whereas in client-side routing, only the JSON file and JS chunk are sent. But why does the HTML file filled with data need to contain JSON data too? Is it really necessary since we already have ...

Dynamic use of a mixin in LESS allows for greater flexibility in

Is it possible to dynamically call a mixin in Less CSS? An interesting use case could be creating a style guide: // Define the mixin that needs to be called .typography-xs(){ font-family: Arial; font-size: 16px; line-height: 22px; } // A mixin att ...

The hidden Material UI Collapse component is still occupying space on the page

Currently, I am implementing Material UI Collapse in my React project and encountering an issue where it is causing unnecessary space on the interface when hidden <Collapse in={false}> //content here </Collapse> Even though I have not a ...

What is the best way to run a JavaScript function once another function has finished executing?

I am looking to ensure that a JavaScript function runs only after another one has finished executing. Here is the code I currently have: $(window).load(function(){ $('#dvLoading').fadeOut(2000); }); window.addLoadEvent = function() { $('#p ...

Maximizing the width of navbar elements with Bootstrap 3

I am currently working on building a webpage with bootstrap3, but I have encountered an issue with the navigation bar. I would like the navigation links ("Web Design", "Development", "Photography", "Blog") to be evenly spaced out within the horizontal na ...

Top Method for Incorporating Syntax Highlighting into Code Blocks - React Sanity Blog

I'm currently exploring the most effective method to incorporate syntax highlighting into my react sanity.io blog. Here's a look at the article component I've developed using react: import React, {useEffect, useState} from "react"; import ...

Enhancing Email Validation with Jquery Livevalidation

Today, I encountered a challenge with live validation. When I tried entering an email in a textbox like <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e06063e0707501d1113">[email protected]</a>, followed by a spa ...

Reset Form - One input retains its previous value

I'm encountering an issue with my form reset button. My form consists of a textarea and a text input that are submitted via Ajax. After the submission, the Ajax response populates the form inputs with new values. However, when I click the reset butto ...

Acquire JSON data using a Bearer token

I am facing an issue with my getJSON script that normally outputs JSON strings. However, it seems to be failing when using a Bearer Token API. Even though I have included the Bearer Token in my HTTP Header like this: authorization: Bearer Mytoken I am no ...

Expandable menu featuring visual icons and a toggle symbol

I am in need of assistance to implement an accordion menu with unique picture icons for each item on the left and a toggle icon (such as + or a chevron) on the right side. Visually, I would like it to resemble this design (https://codepen.io/kathykato/pen ...

Use Select2 for efficient selection

I am attempting to implement select2 for a multi-select dropdown list of states, but I am encountering an issue. Typically, when you type in an option, it should be highlighted so that you can press enter to select it. However, in my case, it underlines t ...

Creating a dropdown link that features an H3 element with Bootstrap 4

Can someone help me with an issue I'm having regarding dropdowns in a navbar? When using a normal nav-link (without a dropdown), I placed the menu text inside an H3 tag, but when I tried to do the same for the dropdown link, the arrow appeared below t ...

Changes in menu layout in response to window resizing

The menu needs to be centered on the website and adjust to the browser window resizing. Currently, it's positioned in the center and the animation is working fine. However, when I attempt to make the menu responsive so that it stays centered when resi ...