Bootstrap page printing in Firefox
I have an index.html generated based on this template: http://startbootstrap.com/template-overviews/sb-admin-2/ with some minor modifications (in my case I used navbar -fixed-top and I changed position at the bottom of the page on sb-admin-2.css)
This index is static, only changing the content of the section through the click event, for example
(Piece of index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>System User Guide</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="all">
<!-- MetisMenu CSS -->
<link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/sb-admin-2.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<script src="js/respond.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="wrapper">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation" style="margin-bottom: 0" id="top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">System</a>
</div>
<!-- /.navbar-header -->
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li class="sidebar-search">
<div class="input-group custom-search-form">
<input type="text" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
<!-- /input-group -->
</li>
<li class="active"><a href="index.html">Home</a></li>
<li><a onclick="openPage('pages/login/loginwelcome.html')" href="#">Login & Welcome</a></li>
</ul>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
</nav>
<!-- Page Content -->
<div id="page-wrapper">
<div class="row">
<div class="col-xs-12">
<div id="content">
<h1 class="page-header">Home</h1>
<p>Welcome to our User Guide.</p>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery Version 1.11.0 -->
<script src="js/jquery-1.11.0.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/plugins/metisMenu/metisMenu.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/sb-admin-2.js"></script>
<script>
function openPage(page) {
$("#content").load(page);
}
</script>
</body>
</html>
(loginwelcome.html)
<html>
<h1 class="page-header">Login & Welcome</h1>
<ol class="breadcrumb">
<li><a href="index.html">Home</a> <span class="glyphicon glyphicon-circle-arrow-right"></span></li>
<li class="active">Login & Welcome</li>
</ol>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#links" class="accordion-toggle" data-toggle="collapse" data-parent="#accordion">Content<span class="glyphicon glyphicon-chevron-down pull-right"></span></a>
</h4>
</div>
<div id="links" class="panel-collapse collapse in">
<div class="panel-body">
<a href="javascript:openPage('pages/login/login.html')">Login</a></br>
<a href="javascript:openPage('pages/login/welcome.html')">Welcome Screen</a></br>
</div>
</div>
</div>
</div>
<p>Test</p>
</html>
So the problem is when I try to print loginwelcome.html in Chrome or IE it works fine (expanding the div width to 100%, disallowing the sidebar, etc.). But when I try to print this in Firefox, there is a huge left margin. I tried to make some changes using bootstrap classes to load and modify media @print in css, but almost the same as if Firefox doesn't recognize changes to media @print. I also tried print_printer reset (roughly: config) and change some of the print settings in this section, but after changing the printer, the problem reappears. Also, I hope there is a better way to do this, or that I am just doing something wrong in my code, because it would be difficult to ask users to do it all in a "workaround".
(Sorry for any mistakes / bad explanation, this is the first time I ask something here)
source to share
It sounds like you might have tried something similar, but it works for me. By the way, I am using bootstrap.
Make sure your DOM element (s) you want to print has a "printable" class.
In your css make sure you have:
@media print {
html, body {
height: 100%;
overflow-x: hidden;
overflow-y: hidden;
}
.printable {
position: absolute;
left: 0;
top: -13%;
width: 100%;
}
// Firefox-specific print styling:
@supports (-moz-appearance:meterbar) {
.printable {
left : -50%;
width : 200%;
font-size: 0.85em;
}
}
}
Take a picture.
source to share
Same issue (type this in Firefox, there is a huge left margin.); the previous answer helped a lot. But I had to set the styling to the container class to get things right (Bootstrap). So identifying the correct div and setting the browser style should work just fine.
@@supports (-moz-appearance:meterbar) {
.container {
margin: 0;
font-size: 0.90em;
width: 100%;
}
}
source to share