Canvas Element Squished in IE10 - javascript

My canvas element distorts in Internet Explorer 9 & 10, it's at half of the height it should be.
The canvas should be a responsive 640x480 box with a large red circle, not an oblong ellipse. I'm hoping it would take a css spec fix, but I'm not clear what the css or javascript fix would be.
In ie10 and ie9 it looks like this:
http://s7.postimg.org/4xtb6vjkr/ie10.png
The code and correct display in chrome, firefox, safari and ie11 can be seen here:
http://jsbin.com/vutiqatowo/1/edit?html,css,js,output
This is a backwards compatibility requirement for a project, so wishing for visitors to not use ie10 is not an option for this.

I'm seeing the replace height:auto with height:100% solution all over googled search results, but it is not working on the pages where it is an issue for me.
I found this media query hack for -ms-high-contrast, and that is working for the distorted canvas display. It's not providing a smooth scaling, but it will do for showing the canvas element correctly.
Here is a fiddle example: http://jsfiddle.net/trents_luck/abhbmsd6/
In the fiddle example, the media query hacks can be seen at the bottom of the css, they read something like this:
#media (-ms-high-contrast: active) and (min-width: 100px),
(-ms-high-contrast: none) and (min-width: 100px)

Related

Responsive Web-design media queries points vs pixels

I have created my website with html, css and javascript and designed it for iPhone X to start off. My website is going to target on Instagram so my main targets are all types of mobile devices. I'm using media queries in css and I want to check for screen height. I'm not sure but it sounds like a good approach for me because for example iPhones don't differ that much in screen width as they do in screen height.
This is my way of approach in css:
#media only screen and (min-height: 481px) and (max-height:666px){*css*}
This should be a query for iPhone 5, but I got really confused by points vs pixels so I was hoping some of you can help me out.
Google chrome shows me the screen size of iPhone 5 as 320 x 568. I was guessing these are supposed to be points but it works just fine with my media query entered in pixels while screen size of iPhone 5 in pixels should be 640 x 1136 pixels.
My media query for iPhone 5 works just fine in Google Chrome iPhone 5 "setup" but I also have a test iPhone 5 at home where responsivity seems not working at all.
So before continuing my responsive design I wanted to have this clear.. Why is this? Is Google Chrome showing points or pixels? Should I use points or pixels in my media queries? Why does it work with pixels in css when they are completely different when I google screen sizes?
I would still consider myself as a beginner so I would really appreciate not too complicated answers.
Thank you!

Firefox and Edge doesn't use my CSS all/media/print when printing

I have an HTML page with a data table and a morris graph apart from some h4 titles.
When I call JavaScript window.print(), Chrome and Safari print correctly, using the CSS and #page for the paper size.
Firefox doesn't use the CSS, just #page for the size, which is landscape as I set it up.
Edge doesn't use the #page or the CSS.
Can someone shed some light?

Scrollreveal.js adding mysterious padding/space to website once window is resized

Noticed that when I resize the browser window on this website a heap of space is added to the bottom, just below the footer.
Disabling the Scrollreveal.js cures the problem, but I want to keep the animations.
The bug is noticeable in Chrome / Safari, Firefox seems to work fine.
I've validated the site but still get the error in these browsers, Has anyone any ideas? I can't even Inspect the space thats generated, also Im using foundation 5 for the framework, maybe something I've changed?
There seems to be an issue with the background that is applied in that area:
Try adding the following CSS to your stylesheet:
#media (max-width: 1024px) {
#contact .columns {
z-index: 2;
}
}

Printing landscape or portrait in FireFox and IE 8

Currently I am using FireFox latest version and IE8
To change the orientation of printing , I used
#page {
size: portrait;
}
in my css file.
#page reference
Although it claims that the #page is supported in both browsers , after my testing it is not working at all besides Chrome. I would like to know how to print the page in different orientation in FireFox / IE8.
No application should depend on this feature to work cross browser right now because the CSS3 standard on page orientation for printing is still under implementation in most browsers.
For Google Chrome it works just fine: http://dev.activisual.net/test.html
Ultimately the decision of changing the orientation relays on the user during the printing process (even if it works), so you could simply let the users know that they should print the page in landscape or portrait, but in general there won´t ever by a way to prevent the users from changing the orientation while printing on desktop browsers.
Here is a bug report for FF reported very recently:
https://bugzilla.mozilla.org/show_bug.cgi?id=851441
You can read the accepted answer on this question for reference:
Landscape printing from HTML
As the MDN reference says:
You can only change the margins, orphans, widows, and page breaks of
the document. Attempts to change any other CSS properties will be
ignored.
As far as supplying you with markup that achieves what you want, that would be outside the bounds of what's allowed on SO. In addition, it could be a bit of work since you are wanting a two generation back version of IE to attempt to perform as well as a current generation Firefox.
Page printing layout is portrait by default, to change to landscape and see the difference try the below.
The the below css code is supported since version 19.0 , try it, it should solve your problem:
For IE8 you should use HTML5 directive in your html
<!doctype html>
Css code :
#media print{#page {size: landscape}}
Firefox: https://developer.mozilla.org/en-US/docs/Mozilla_CSS_support_chart
IE http://msdn.microsoft.com/en-us/library/hh781508(v=vs.85).aspx
It's weird that this
{
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
doesn't work for you for the latest version of Firefox as i tested it myself and works fine.
If you can't find anything have a look here even though this isn't exactly the right portrait mode (for printing) but you might get some ideas.
Lastly if you get desperate and u really need to find a way to do this, you can always take a screenshot of the web page with for example html2canvas rotate the image and then print the image instead of the webpage...
Not an ideal solution but this way you bypass the browser.
I ran into this issue a little wile ago while making a simple form.
Chrome does seem to be the best browser for limiting a users control over the printing process. However it is still limited, and Firefox/other browsers don't support #page.
My solution was to add a #media print to the style sheet to "encourage" the user to print the page in portrait. The #page is just for chrome. display: none; on the header, nav, and footer gets rid of the unwanted browser additions (this only works in chrome and firefox, in ie you still have to select no headers) I have a border:0; on input fields, because it was for a form...
Finally I put a width and height on the container div, similar to the size of a standard 8.5 x 11 piece of paper. So it would fit the page nicely.
#media print{
#page {size: auto; margin: auto;}
header nav, footer {display: none;}
input {border: 0px;}
#container {width:9.1in; height:10in;}
}
Ultimately webpage printing is still very browser/user dependent, and there really isn't much that can be done about it. Making #media print helps, but really the only way to get the page to print exactly as you want would be to generate a pdf version of the page that the user could export.
Just go to file, click on page setup and change the orientation. This works for me

Detect small (mobile) screen in Javascript (or via css)

I want to make some of the fonts on my website larger, if a visitor is using a small screen. Ideally without jquery, as I want to do this early on in the page load, and I don't want to load jquery until later, for faster loading.
The best I have come up with, is to check for screen size. But this is far from perfect. An iphone4 has relatively large size, but small screen, while some old netbook might have a smaller resolution but a larger screen. I guess what I really want is some variant of screen "DPI".
If there is some css way of saying "on a small screen do this, else on a large screen do that" that would work too.
In CSS2 there's a media property and in CSS3 this can be used to do media queries. It's not supported on all browsers, but it may be okay to use since your small devices like iPhone etc do support it.
#media screen and (min-width: 781px) and (max-width: 840px) {
body {
font-size: 13px;
}
}
This site doesn't care about IE, try it in FF or Safari, change the browser width and notice how the width changes using this property.
Media Queries are the key and are a lot of fun to use.
See http://jsfiddle.net/neebz/kn7y3/ and change the width/height of the 'Result' panel to see it working.
Example taken from : http://www.maxdesign.com.au/articles/css3-media-queries/media-sample/

Categories

Resources