I'm trying to make a wordpress page that grabs some dynamic content and puts in on a page that is ready for someone to easily print. There are two things that are getting in the way and some help would be great.
after pressing print initially in chrome the page looks a mess - overzoomed so it is incomprehensible. If i dial "scale" back to 60 it looks pretty much like the webpage. I've tried setting #media print scale to .6 but that seems to just shrink the messy view into the middle of the page. Any ideas?
initial messy zoom at 100%
if i take the zoom down to 60% perfect
some text on the page insists that it prints in black. no amount of alteration on the site will change that. it appears white on the web, prints in black. Any ideas?
thanks.
nick
Some text on the page insists that it prints in black, no amount of alteration on the site will change that. It appears white on the web, prints in black. Any ideas?
When printing, the Chrome browser applies its own styling to the page. On your page, the text is changing from white to a dark grey because Chrome is removing the blue element behind it. Without the blue element behind the white text, it'd just be white text on a white background, so Chrome has gone ahead and 'fixed' that for you so that it's readable.
If you're looking at the print settings in Chrome, you'll see a 'More Settings' option. If you open that, you'll see that Chrome has given the user the option to remove the background graphics as seen below.
By default, this button is unchecked in Chrome. This is a very intentional feature of Chrome that allows users to save ink when printing from the web. Browsers can do whatever they want when printing, so some things may simply be out of your control.
You can change the styling for the print page by using the #media CSS query. You still need to keep in mind specificity when using the #media query. If Chrome is ignoring one or more of your attributes, you can try using !important with whatever you're trying to change.
Example
#media print {
.my-class {
color: blue;
}
#my-id {
color: green;
}
.stubborn-div {
color: red !important;
}
}
You could also try this:
-webkit-print-color-adjust: exact;
When set to exact, the background colors and images of the element to which this rule is applied are always printed, user's print settings are overridden. Note that support is extremely limited to what browsers can & will use it. See here.
After pressing print initially in chrome the page looks a mess -
overzoomed so it is incomprehensible. If I dial "scale" back to 60 it
looks pretty much like the webpage. I've tried setting #media print
scale to .6 but that seems to just shrink the messy view into the
middle of the page. Any ideas?
I've looked at your code enough that I really think it just comes down to you figuring out your responsive styling, and adding the necessary CSS to the #media query.
It's impossible to be sure about anything because you haven't posted a stitch of code. Have you tried setting
body{ height:100vh; width:100vw; }
?
Are you aware that there are "print styles"? I.e. you use the media query #media print { ... } in your CSS and there write CSS rules for everything that should be different in the printout.
You can for example change font sizes for classes, tags, or the whole body, you can change (text) colors, and you can even hide stuff in the printout, like menu bars and sidebars, by using display: none for these elements in the print styles.
Related
In my first attempt at a responsive web design I have run into a curious problem. When I resize my browser down to 615px width or less, a horizontal scroll bar appears. I'm not sure what element is causing this. I tried putting a border around each element using
* {
border:1px solid #FFF;
}
to help me visualize where the edges of the elements were but I don't see any borders extending beyond the window boundaries.
Can someone take a look at my site and give me some insight? http://www.ritualbliss.ca
Thanks!
Edit: So I only get the scroll bar in Firefox. Chrome works fine and the desktop version of Safari but on my iPhone it scrolls horizontally.
Edit: the site is for a legitimate massage business but some may consider the picture NSFW
Devin,
Try using a tool like Firebug for Firefox, IE Developer Tools, or the Chrome Developer tools. I'm sure Safari and Opera have similar tools, as well. These things will give you the ability to highlight and view the various properties of every visible HTML element on the page, including Javascript and CSS information.
One other thing to think about is not using the * selector in your CSS. I am not sure why you would want to put a border around every single element on your page because to me, that would not look visually appealing. The border style attribute adds the thickness of the border to whichever dimensions it is applied to. So, in your case, every element in your page has 2px added to both its height and width, even the "html" element. This could be why you have the scroll bar but can't tell where the extra pixels are.
Also, do you have any CSS styles that set a width or min-width to 617 pixels? Or a combination of elements that share the same area and add up to 617 pixels? Maybe a table with columns that are not shrinkable?
There is a lot to look at and your URL looks like it's probably porno or something so I cannot go there at work and check it out...
Good Luck,
Matt
Edit
I fooled around with firebug for a few minutes and agree with Ruben that handling the overflow would be a good idea. Although I think the setting should be on the body instead of #content.
Try this:
body { overflow-x: hidden; }
Like Ruben's answer it is hiding overflow, but you can still get the vertical scrollbar if people REALLY narrow down their browser.
can you please warn us when it's nsfw :s
use this css:
#content { overflow: hidden }
not the best solution but you have to use firebug to find out what's sticking out
padding and borders increase the width of your element too
css3 box-sizing:border-box solved this one.
http://fiddle.jshell.net/bTtKT/show/
If I print the above page in Chrome as A4 Landscape I get two pages as expected given the size of the canvas on the page, if I do the same in Firefox however (with print preview for example), it gives me only one page and therefor cuts the image/canvas in half. If I change the scale in Firefox however I do start to see the whole image (but then it's too small), so the image is there as a whole but Firefox seams to ignore that its bigger then one page for some reason.
How do I get Firefox to recognize that the image needs more then one page so I can print the whole thing in correct size?
(possible to edit the above page example here: http://jsfiddle.net/bTtKT/ )
I didn't try it out, but you could try:
canvas { page-break-inside: avoid; }
See: https://developer.mozilla.org/en/CSS/page-break-inside
Putting this style on the div encompassing the canvas might help ya:
page-break-inside: avoid
clear: both
float: none
What CSS property should I change at this page to disable transparency of a share iframe which appears when Like button is clicked?
When you hover on that Facebook box after clicking Like button, it becomes partially transparent and if you move your cursor away from it, it becomes solid white. I want it to be completely opaque all the time.
Well, I see no transparency on that box, only for the fade-in effect when it opens, but once it's fully opened it's not transparent.
To answer your question, you can see for yourself using firebug (firefox) or the development tools (chrome/safari) which css rules apply to what element.
From what I've seen now, you can use the use these: fb_edge_comment_widget fb_iframe_widget which are the classes of the span containing the iframe, or you can use the iframe itself.
The thing is though, is that you should not hack that. Why? Since then you'll have to always check for updates facebook are making, changes that they do not update you about (API changes they update on the blog), if you fail to be aware of these changes it can "break" your code/style.
I was also having the exact same problem.
I am using an AddThis widget set, and I don't know if this was the case for you or not (it looks like you may have chosen a different solution as I can't see the Like button on your site).
I ended up using
.addthis_button_facebook_like {
opacity:1 !important;
}
but you would use whatever selector that wrapped your like button. if using the standard embed from Facebook, it would probably be
.fb-like {
opacity:1 !important;
}
Someone else was having a similar problem with a Send button, which got me on the right track.
See it working like it ought to here. I'm sure it had something to do with some conflict from other styles, or possibly AddThis, but it's working now!
I am using GWT 2.3 to create a web application. In the web page, I have a button for the submission. I haven't created any css properties for this button. In Google Chrome and Firefox, the size of the button is just the size of the text of the button. However, in IE8, the size is bigger, with some spaces before and after the text of the button. Does any body know how should I do? Since I need to support the internationalization, the texts of the button for different locales are different.
I have tried width:auto; for the button, but it doesn't work.
Thanks in advance!!
Ah, this is an oldie but goodie.
Basically, IE sucks at rendering buttons and you have to add this CSS to fix it:
.my_button {
/* optional */
padding:0 .25em 0 .25em;
/* These two are required */
width:auto;
overflow:visible;
}
See the link above for more information.
In general (not only for GWT), buttons are rendered very differently not only between browsers, but also between operating systems - especially they look completely different on Mac OSX. Take a look at this site, which also has a few nice solutions around the button problem: http://particletree.com/features/rediscovering-the-button-element/
So if you need exact sizes (and maybe a consistent look) across browsers/OS, I think it's better not to use the native button style at all, but to fully customize the style of your buttons. (This is pretty usual on modern web sites, e.g. I don't think there are any native style buttons on stackoverflow.com at all.)
Use Anchor with different background images for it's various states (link, active, hover, visited).
When printing the page below in Safari/Chrome, the content (everything on the page, basically) is squished into the left side of the page, at about 60% of the page's width.
However, in FireFox and IE 7, the printed page shows the content as the full width (and looks quite nice, imo). I resized all the layout elements to 100% width (using !important to make sure they're applying), and Safari/Chrome still won't print out the full width.
Here's the page I'm referencing:
http://archstl.org/commoffice/press-release/2010/local-catholic-principal-honored-fi
And here's an image of the difference between Webkit (first) vs. Gecko (second):
(source: skitch.com)
(source: skitch.com)
sorry not really an answer but a comment(i can't comment yet) but, have you tried printing the sheet already? if not, just try it.
Also, I checked your print.css and although I'm not too sure, maybe you can check your font-sizes. Try using pixels first instead of em. Since em is relative to your base font size, it may vary in browsers. You can rectify this by adding a fixed font size in your body style like so:
body { font-size: 13px; }
then continue using em for the others.
I've decided to give up on trying to improve the print stylesheets anymore, and instead just accept the odd spacing issues in different browsers.
I would recommend, to anyone else trying to style your pages for print, to consider using #screen instead of #all for your main site stylesheets, though—this makes styling things for print easier on some more complex layouts.
Anyways, we should just move into the 21st century and forget about printing ;-)