How to resize/make it responsive with css?
See original GitHub issueI’ve follow this video tutorial: https://www.youtube.com/watch?v=qzbHxlQAa5o, but can’t get the css to work.
html:
<div id="barcode-scanner"></div>
.ts
private _initQuagga() {
Quagga.init({
inputStream: {
name: 'Live',
type: 'LiveStream',
target: document.querySelector('#barcode-scanner')
},
decoder: {
readers: ['code_128_reader']
}
}, (err) => {
if (err) {
this.logger.error('Err. on initializing Quagga:', err);
return;
}
this.logger.debug('Quagga initialized.');
});
}
.scss
#barcode-scanner video, canvas {
width: 100%;
height: auto;
}
#barcode-scanner video.drawingBuffer, canvas.drawingBuffer {
display: none;
}
The css just doesn’t do anything on the video/canvas, even with !important
it changes nothing.
I also tried downgrading to 0.11.6 which is the same version as the video, but still can’t get it to work.
Setting the video’s width from Chrome’s inspector works perfectly though.
Btw, there’s also a canvas floating to the right taking a massive blank space which can’t be hidden with css, how to fix this?
More infos: Angular: 5.2.0 quagga: 0.12.1
Thank you very much!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Responsive Web Design Images - W3Schools
Resize the browser window to see how the image scales to fit the page. Using The width Property. If the width property is...
Read more >How to Resize Images Proportionally for Responsive Web ...
Another way of resizing images is using the CSS width and height properties. Set the width property to a percentage value and the...
Read more >How to Resize Images Using CSS for Responsive Web Design
How to resize an image with CSS · Option 1: Resize with the image width attribute · Option 2: Resize with the max-width...
Read more >Resize image proportionally with CSS? - html - Stack Overflow
To resize the image proportionally using CSS: img.resize { width:540px; /* you can use % */ height: auto; }.
Read more >Resize image proportionally with CSS - GeeksforGeeks
The resize image property is used in responsive web where image is resizing automatically to fit the div container.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got it working, seems to be extremely ugly though:
I just tested to see if my css would change the
canvas
element that I created myself, outside of the barcode-scanner div. It did, but it also prevented the canvas of the scanner being created automatically (LOL).So next thing I did, was to put the canvas and a video tag inside the
barcode-scanner
div. And that worked.Reading barcodes with the webcam is quite unreliable and hard… lightning, distance between the barcode and webcam, etc… all affects reading. Even with a buffer, it still reads wrong most of the time. I haven’t tweaked the settings yet, so there might still be hope on getting better and faster readings. Right now takes me about 30-40 seconds to read 20 samples.
Not sure about mobile, after about 30 minutes fiddling my android’s chrome settings, I couldn’t find how to allow permissions for the camera. Probably need to serve the app through https or sth.
A better option for mobile, would be cordova-plugin-barcodescanner currently discontinued 😞
do this where #scanner-container is the id you your div.this works fine. #scanner-container > video { width: 100%; height: 100%; }
#scanner-container > canvas.drawing, canvas.drawingBuffer { position: absolute; left: 0; top: 0; }