Along with the development of web technologies and web programming languages, web designing becoming more complex and the websites more flexible and user friendly. With the invention of CSS technology, web designing and programming becoming more easier than ever.
By using cascading style sheet (CSS) and its properties, you can give custom design to your website for different medias like screen, print, tv and for different screen sizes. The CSS @media property allows you to do such task.
Today I am going to describe "How to create custom CSS template for printing".
If you wanted to allow your website visitors to print the content of your website, you can design custom template for printing using CSS. You can define which part or your website will be printed or not and can add page setting for printing.
By using cascading style sheet (CSS) and its properties, you can give custom design to your website for different medias like screen, print, tv and for different screen sizes. The CSS @media property allows you to do such task.
Today I am going to describe "How to create custom CSS template for printing".
Designing Custom CSS Template for Printing
If you wanted to allow your website visitors to print the content of your website, you can design custom template for printing using CSS. You can define which part or your website will be printed or not and can add page setting for printing.
Here is a sample CSS code for website template.
body{
background:#00aaff;
font-color:#00000;
font-size:16px;
}
h1, h2, h3 {
/* CSS codes for h1, h2, h3 */
}
#wrapper{
width:80%;
margin: 0 auto;
background:#fff;
padding:20px;
}
#content{
width:54%;
float:left;
margin-right:3%;
}
#header{
width:100%;
margin-top:2%;
}
#sidebar-left{
width:20%;
float:left:
margin-right:3%;
}
#sidebar-right{
width:20%;
float:left;
}
#footer{
width:100%;
}
While printing you can hide default header, menu and sidebar using CSS codes. Here is a sample CSS code for printing webpage.
body{
background:#00aaff;
font-color:#00000;
font-size:16px;
}
h1, h2, h3 {
/* CSS codes for h1, h2, h3 */
}
#wrapper{
width:80%;
margin: 0 auto;
background:#fff;
padding:20px;
}
#header{
display:none;
}
#content{
width:100%;
clear:both;
margin-right:3%;
}
#sidebar-left{
display:none;
}
#sidebar-right{
display:none;
}
#footer{
display:none;
}
Place the above CSS code inside media queries for printing as below.
@media only print and (orientation:portrait) {
/* Add CSS code here for printing on portrait mode */
}
@media only print and (orientation:landscape) {
/* Add CSS code here for printing on landscape mode */
}
Adding Printing function and icon
Add the following HTML code where you want to place print icon.
<a href="javascript:window.print()"> Print this page </a>
Using this code the print link looks like as below Print this page
<a href="javascript:window.print()"> <img src="print.jpg"></a>
Using this code the print icon looks like as below
<form><input type="button" value="Print This" onclick="window.print()"></form>
Related Posts:
- How to Create Responsive Website or Blogger Template
- How to Create Simple Blogger Template Easily?
- How To Make Simple CSS Stylesheet for a Website ?
- How To Create Simple Menu Using CSS ?
- How to validate required field in a form using javascript
- How to Display Date Format in JavaScript?
- How to Create a Digital Clock in JavaScript?
- What are the Different Ways to Redirect Page in JavaScript?
- How to Detect Visitor's Browser Using JavaScript?
- Image Slideshow with Navigation Buttons Using Javascript
- How to Create Simple JavaScript Fade Effect Animation?
- Simple JavaScript Fade Effect Animation Using Jquery
ليست هناك تعليقات:
إرسال تعليق