Showing posts with label css. Show all posts
Showing posts with label css. Show all posts

Sunday, April 9, 2017

How to create fade effect image slideshow using CSS

How to create fade effect image slideshow using CSS



You can give fade effect animation for image slideshow using CSS. @keyframes at rule and animation keyword in CSS can be used to make image slideshow with fade effect. With @keyframes at rule, you can define the properties that will be animated in an animation rule and animation keyword to set all of the animation properties.


Here I have used different types of animation properties like animation-name, animation-duration, animation-timing-function and animation-iteration-count. Where animation-name specifies name of the animation, animation-duration specifies animation duration in second(s) or milisecond(ms), animation-timing-function specifies how the animation will play like ease, ease-in, ease-in-out, ease-out and linear and animation-iteration-count:number of times animation should play.

Simple fade effect image slideshow 

 
Here is a sample CSS code for creating simple fade effect image slideshow written for safari browser.

<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;
position:relative;-webkit-animation-iteration-count:infinite;}
</style>

Here is a full HTML code along with required JavaScript code for creating simple fade effect image slideshow.

<head>
<title>CSS Animations</title>
<style type="text/css">
@-webkit-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-moz-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-o-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
@-ms-keyframes fade{
from {opacity:.5;}
50% {opacity:1;}
to {opacity:.5;}
}
#anim1 {-webkit-animation-name:fade;-webkit-animation-duration:5s;
-webkit-animation-iteration-timing-function:linear;position:relative;
-webkit-animation-iteration-count:infinite;-moz-animation-name:fade;
-moz-animation-duration:5s;-moz-animation-iteration-timing-function:linear;
-moz-animation-iteration-count:infinite;-o-animation-name:fade;
-o-animation-duration:5s;-o-animation-iteration-timing-function:linear;
-o-animation-iteration-count:infinite;-ms-animation-name:fade;
-ms-animation-duration:5s;-ms-animation-iteration-timing-function:linear;
-ms-animation-iteration-count:infinite;}
</style>
<script language="JavaScript">
var i = 0;
var path = new Array();

// LIST OF IMAGES
path[0] = "image1.jpg";
path[1] = "image2.jpg";
path[2] = "image3.jpg";

function swapImage1()
{
document.slide.src = path[i];
if(i < path.length - 1) i++; else i = 0;
setTimeout("swapImage1()",5000);
}
window.onload=swapImage1;
</script>
</head>
<body>
<div id="anim1"><img height="400" name="slide" src="image_1.gif" width="600" />
</div>
</body>
</html>


In the above code prefixes -webkit-, -moz-, -o-, -ms- are used for browsers safari, firefox, opera and internet explorer respectively.

Here is a preview of image slideshow for the code above.


slide


Fade effect image slideshow with caption


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.


// LIST OF CAPT?ONS 

caption[0] = "Caption for the first image";

caption[1] = "Caption for the second image";

caption[2] = "Caption for the third image";

function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption on image slideshow visit the post: How To Create Simple Image Slideshow Using JavaScript ?


Fade effect image slideshow with caption and link


You can add caption for this slideshow by adding following JavaScript codes within <script> tag.



var link= new Array(); 

link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";


function swapImage(){

var el = document.getElementById("mydiv");

el.innerHTML=caption[i];

var img= document.getElementById("anim1");

img.src= image[i];

var a = document.getElementById("link");
a.href= link[i];

if(i <k ) { i++;}

else { i = 0; }



For details on adding caption and link on image slideshow visit the post: How to Create JavaScript Image Slideshow with Links



Related Posts:

  • How To Create Simple Image Slideshow Using JavaScript ?
  • How to Create Simple JavaScript Fade Effect Animation?
  • Image Slideshow with Navigation Buttons Using JavaScript
  • How to Create JavaScript Image Slideshow with LInks
  • Simple JavaScript Fade Effect Animation Using Jquery


Go to link Download

Read more »

Friday, February 10, 2017

How to Create Custom CSS Template for Printing

How to Create Custom CSS Template for Printing



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".

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.

Designing Custom CSS Template 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>

Print
Using this code the print icon looks like as below


<form><input type="button" value="Print This" onclick="window.print()"></form>

Using this code the print button looks like as below                                                            



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 Visitors 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

    Go to link Download

    Read more »

    Sunday, December 25, 2016

    How to make rounded corners border using CSS

    How to make rounded corners border using CSS



    While designing website, website template or blog template, you may want to make buttons, menus, paragraphs or any others border corners rounded to make your template more beautiful and attractive. It is possible by using a keyword "border-radius" in CSS. The keyword border-radius is used to make all the corners rounded by specifying the radius of corner. For example you can use the following CSS code.
    rounded corners border using CSS

    border-radius:10px;                    // makes radius of all the corners 10px;

    You can also specify the radius for each corners by using border-radius-top-right, border-radius-top-left, border-radius-bottom-right, border-radius-bottom-left keywords. For example you can use the following CSS code to make each corner rounded.

    border-radius-top-right:10px;
    border-radius-top-left:10px;
    border-radius-bottom-right:5px;
    border-radius-bottom-left:5px;

    The above code makes radius of left and right corners of top side 10px and radius of left and right corners of bottom side 5px.

    To makes this CSS code browser specific or specific browser compatible, you have to use the prefix codes like -moz- for mozilla firefox and -webkit- for chrome or safari.


    .all{

    border:2px solid red;

    -moz-border-radius:10px;

    -webkit-border-radius:10px;

    border-radius:10px;

    width:250px;

    }

    .topleft{

    border:2px solid red;

    -moz-border-top-left-radius:10px;

    -webkit-border-top-left-radius:10px;

    border-top-left-radius:10px;

    width:250px;

    }

    .topright{

    border:2px solid red;

    -moz-border-top-right-radius:10px;

    -webkit-border-top-right-radius:10px;

    border-top-right-radius:10px;

    width:250px;

    }

    .bottomleft{

    border:2px solid red;

    -moz-border-bottom-left-radius:10px;

    -webkit-border-top-left-radius:10px;

    border-bottom-left-radius:10px;

    width:250px;

    }

    .bottomright{

    border:2px solid red;

    -moz-border-bottom-right-radius:10px;

    -webkit-border-bottom-right-radius:10px;

    border-bottom-right-radius:10px;

    width:250px;

    }


    Use above CSS code with the following HTML code given.

    <html>
    <head>
    <title>CSS code for rounded corners</title>
    <style type="text/css">

    //place the abobe CSS code

    </style>
    </head>
    <body>
    <div class="all">All rounded corners</div>
    </br>
    <div class="topleft">Topleft rounded corner</div>
    <br/>
    <div class="topright">Topright rounded corner</div>
    </br>
    <div class="bottomleft">Bottomleft rounded corner</div>
    <br/>
    <div class="bottomright">Bottomright rounded corner</div>
    </body>
    </html>

    You can view the following rounded corners for 2px solid red border and 250px width having 10px radius of corners.


    All rounded corners

    Topleft rounded corner

    Topright rounded corner

    Bottomleft rounded corner

    Bottomright rounded corner


    Here I have used <div> tag, so these shapes are appeared with line break. If you wanted to place these shapes on the same line you can use <span> tag. You can also use <p> tag with the place of <div> tag.

    You can apply these rounded corners shapes to make CSS buttons, menus etc. Here is a sample code to make CSS button along with background color.

    <div style="border:2px solid light-blue; -moz-border-radius:10px;
    background-color:blue; z-index:10;-webkit-border-radius:10px;
    border-radius:10px;width:110px;text-align:center;
    color:white;cursor:pointer;">
    CSS button
    </div>

    CSS button



    Related Posts:



    • 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 Visitors 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

    Go to link Download

    Read more »