I've made website with bootstrap fixed navbar. It has fixed navbar so in stylesheet body have top-padding of 70px.
When i print the page it add that extra space at top of paper. What can i do to remove that extra space causing by that top-padding.
Below is print preview with padding
Below is print preview without padding which i want with less space at top.
If i remove the padding the print is as i want but the in browser the content get behind the nav bar and i can't see the first 2-3 lines.
Please give me some solution to retain the fixed navbar and also the padding don't get include in print.
Add a new print stylesheet like so (place this after your main stylesheet):
<link rel="stylesheet" href="/css/print.css" media="print">
In print.css set your new CSS rule for the body tag like so:
body {
margin-top: 0;
}
I know you may or may not want to show the navbar in print. I wanted to show it, so I added this in my CSS (Bootstrap 3):
@media print {
.navbar {
display: block;
border-width:0 !important;
}
.navbar-toggle {
display:none;
}
}
The accepted answer works perfectly, but if you don't want to add a new style sheet, an alternative is to wrap the body padding in a media tag. In your Site.css:
@media screen {
body {
padding-top: 50px;
padding-bottom: 20px;
}
}
This specifies that the style should only be applied when viewing the page, not printing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With