Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print media query for img max-width breaks Google Maps printing in Chrome #1741

Closed
rdlugosz opened this issue Oct 8, 2015 · 8 comments
Closed

Comments

@rdlugosz
Copy link
Contributor

rdlugosz commented Oct 8, 2015

Somewhat related to the issue with images in IE8 (#984), after a long search I've discovered that line 260 in the H5BP print media query breaks printing of Google Maps if your browser is too wide (or, more specifically, if the map div is wider than ~800px). I've seen this on several WebKit browsers; example below tested on Chrome 46.

The map will look fine on screen, but when you hit print you'll notice that all of the tiles are missing. I've created a demonstration here . Note that the only file changed in this repo from the default H5BP install is index.html.

The simple fix is to override the style via:

@media print {
  img {
    max-width: none !important;
  }
}

... but this took me a rather long time to discover (on and off for weeks until finally digging in with process of elimination). Is there a reason why this style is being set?

It strikes me that this could be considered a Google Maps bug and not that of H5BP, but thought this would be a better place to start. After all, a stock browser does not exhibit this problem until H5BP is introduced.

@cvrebert
Copy link
Contributor

X-Ref: twbs/bootstrap#1506

@rdlugosz
Copy link
Contributor Author

Is that bug really related? This is specifically related to the print styles, not the regular img display.

@cvrebert
Copy link
Contributor

Same underlying issue, which is that img { max-width: 100%; } isn't compatible with Google Maps (among other widgets, e.g. Mapbox). The only difference is that in h5bp the problematic CSS is within a print media query.

@alrra
Copy link
Member

alrra commented Jan 14, 2016

Is there a reason why this style is being set?

@rdlugosz It was introduced in order to prevent images from getting cut off on print.

@rdlugosz
Copy link
Contributor Author

That's reasonable, but while it fixes a problem with images being cut off,
it creates an arguably more unexpected result with several mapping systems.

Any thoughts on how this could be adapted to solve the basic image problem
while not impacting the way the mapping frameworks work?

Or, would this be better resolved via a readme or FAQ item?

On Thursday, January 14, 2016, Cătălin Mariș notifications@github.com
wrote:

Is there a reason why this style is being set?

@rdlugosz https://github.com/rdlugosz It was introduced
b2faa1f
in order to prevent images from getting cut off on print.


Reply to this email directly or view it on GitHub
#1741 (comment)
.

@QWp6t
Copy link
Contributor

QWp6t commented Jan 14, 2016

Just read the solution in the link @cvrebert posted.

img[src^="http://maps.gstatic.com/"], /* map view */
img[src^="http://maps.googleapis.com/"] /* street view */
{
  max-width: none !important;
}

@cvrebert
Copy link
Contributor

s/the solution/a mediocre solution/

@paulirish
Copy link
Member

If it's good enough for bootstrap, then why not. :)

Open to a PR like twbs/bootstrap#19000

rdlugosz added a commit to rdlugosz/html5-boilerplate that referenced this issue Aug 9, 2016
Following the lead of Twitter Bootstrap (see: twbs/bootstrap#19000), remove the print media query that sets a max-width of 100% to images. This code was meant to prevent images from being cut off in print, but has a side effect of causing map tiles to disappear when printing medium-to-large maps (e.g., with Google Maps).

For reference, this style was added to H5BP in h5bp@b2faa1f
roblarsen pushed a commit that referenced this issue Aug 15, 2016
Following the lead of Twitter Bootstrap (see: twbs/bootstrap#19000), remove the print media query that sets a max-width of 100% to images. This code was meant to prevent images from being cut off in print, but has a side effect of causing map tiles to disappear when printing medium-to-large maps (e.g., with Google Maps).

For reference, this style was added to H5BP in b2faa1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants