Showing posts with label HTML&CSS. Show all posts
Showing posts with label HTML&CSS. Show all posts

Sunday, 24 May 2015

How To Create a Layout In HTML5

HTML5 layout
Here is a very simple way you can create a new HTML5 layout. This is a responsive layout that means this will fit to any screen. you can check this by decreasing the width of your browser,  this will adjust with the screen. Here we use width as percentage(%), this will adjust the site with your screen.











<!DOCTYPE html>
<html>
<head>
 <style>
            /* Here is the CSS code */
 *
 {
  margin: auto;
 }
 h2
 {
  text-align: center;
  color: #fff;
 }
 header
 {
  width: 100%;
  height: 100px;
  background-color: #400000;
 }
 aside
 {
  width: 30%;
  height: 600px;
  float: left;
  background-color: #660066;
 }
 section
 {
  width: 100%;
  height: 600px;
  background-color: #663399;
 }
 footer
 {
  width: 100%;
  height: 50px;
  background-color: #400000;
  clear: both;
 }
 </style>
</head>
<body>
<!-- This is html code-->
<header>
 <h2>I am Header</h2>
</header>
<aside>
 <h2>Side Bar</h2>
</aside>
<section>
 <h2>Section</h2>
</section>
<footer>
 <h2>Footer</h2>
</footer>
</body>
</html>

Sunday, 17 May 2015

How To Create Your Own Video Player In HTML5

Video Player In HTML5
 This is a simple video player built using  HTML5  and javascript. copy and paste this  code into your  code editor and run. before  running this code  replace the video source by  your own video i.e  <source  src="media/myvideo.mp4"  type="video/mp4">  and also the replace the the  button images. or  simply rename the buttons as  play,pause,stop,forward,reverse.



 Description of java script functions:
   playVideo():
 here we first declare a variable that is vid and we store the value of document.getElementById("video");. we call this variable because this is much easier to write then to write document.getElementById("video") each time we call a function. so here is the vid.play() function is used to play the video. play() is a javascript built in function to paly any video.

pauseVideo()
    vid.pause() function is used to pause the video and is quite similar to play function because both play and pause are both built in function. 

stopVideo()
       To stop a video we have to think tricky because when we press the stop button it works two things, first it pauses the video and then it takes the video to the initial position. so here we first use the vid.pause() function to pause the video and then we change the current time to 0. i.e if the video was at 30 seconds the vid.currentTime=0; takes this to the 0 position.

fwdVideo()
      fwdvideo() function is used to forward the video this means we are increasing the current time of the video. so we simply use the increment operator in javascript i.e ++ to increment the current time by 1s. vid.currentTime++ means increase the current time by 1 second.

revVideo()
   revVideo function is used to rewind the video this means we are decreasing the current time of the video. so we simply use the decrementt operator in javascript i.e -- to decrement the current time by 1s. vid.currentTime-- means decrease the current time by 1 second.

setDuration()
   setDuration() function is used to set the total time of the video.  Here we call the id totalTime and set the total time by using the function vid.duration. Math.round() is a javascript function to round off the number.

updateTime()
  updateTime() function is used to check for the current time of the video. For this we set the id timeText for current time and call the function vid.currentTime().

volumeUp()
    This function is used to increase the volume of the video.here vid.volume+=.1 means increment the vid.volume to .1. Here the range is between 0.1-0.9. And the next we use Math.round(vid.volume*10) this converts the range to 1-10 and round of the values.



 <!DOCTYPE html>
<html>
<head>
    <title>Media Player</title>
    <style>
    body
    {
        background:-webkit-linear-gradient(left,blue,green);
       background:-moz-linear-gradient(left,blue,green); 
        <!--this is the CSS3 linear gradient color -webkit is for chrome and -moz is 
         used for mozila firefox. -->
     }
    .media
    {
        width: 450px;
        height: 480px;
        margin: auto;

    }
    .player
    {
        background-color: #480000 ;
        padding:20px;
        width: 350px;
        height: 300px;
    }
    .btn
    {
        float: left;
          }

    </style>
</head>
<body>
<div class="media">
<div class="player">
<!--This is the video tag used in HTML5, we set the width and height for the video,
the setDuration() function is used to determine the total length of the video 
and the updataTime() function is used to check the current time of the video--> 
 <video id="video" width="345" height="200" onloadedmetadata="setDuration();" ontimeupdate="updateTime();">
    <source src="media/myvideo.mp4" type="video/mp4">
    Browser not supporting..:(
</video><br>
 <p>total time<span id="totalTime">x</span/> seconds<br/>
current time <span id="timeText">xx</span> seconds</p> 
 <div class="btn">
<!--these are the buttons and when you click a button it calls a javascript function--> 
 <button type="button" onclick="playVideo();"><img src="media/player_play.png" width="30" height="30"></button>
<button type="button" onclick="pauseVideo();"><img src="media/player_pause.png" width="30" height="30"></button>
<button type="button" onclick="stopVideo();"><img src="media/player_stop.png" width="30" height="30"></button>
<button type="button" onclick="fwdVideo();"><img src="media/player_forward.png" width="30" height="30"></button>
<button type="button" onclick="revVideo();"><img src="media/player_backward.png" width="30" height="30"></button>
<button type="button" onclick="volumeUp();"><img src="media/audio_volume_high.png" width="30" height="30"></button>
<button type="button" onclick="volumeDown();"><img src="media/audio_volume_low.png" width="30" height="30"></button>
</div>

</div>
</div>
<script>
     vid=document.getElementById("video");
    function playVideo()
    {
        vid.play();
    }
    function pauseVideo()
    {
        vid.pause();
    }
    function stopVideo()
    {
        vid.pause(); 
        vid.currentTime=0;
    }
    function fwdVideo()
    {
        vid.currentTime++;
    }
    function revVideo()
    {
        vid.currentTime--;
    }
    function setDuration()
    {
        document.getElementById("totalTime").innerHTML=Math.round(vid.duration);
    }
    function updateTime()
    {
        document.getElementById("timeText").innerHTML=Math.round(vid.currentTime);
    }

    document.getElementById("volume").innerHTML=Math.round(vid.volume*10);

    function volumeUp()
    {
        vid.volume+=.1;
        document.getElementById("volume").innerHTML=Math.round(vid.volume*10);
    }
    function volumeDown()
    {
        vid.volume-=.1;
        document.getElementById("volume").innerHTML=Math.round(vid.volume*10);
    }
</script>
</body>
</html>

Tuesday, 24 March 2015

How To Create a Slider Using HTML and CSS3

slider using html and css

Hi guys here i am going to share with you a very simple css3 image slider, you can put this code in your slider area to get a slider in your website. You can change the images in css.

<!doctype html>

<html>

<head>

<style>

*

{
 margin:auto;
    }
.wrapper
{
 background-color:#E48939;
 width:960px;
 height:800px;
}
.slider
{
 width:600px;
 height:300px;
 float:left; 
 margin:250px 0px 0px 180px;
 -webkit-animation:slider 20s infinite;
}
@-webkit-keyframes slider
{
 0%{background-image:url(img1.jpg); background-size:600px 300px;} 
 25%{background-image:url(img2.jpg); background-size:600px 300px;}
 75%{background-image:url(img3.jpg); background-size:600px 300px;}
 100%{background-image:url(img4.jpg); background-size:600px 300px;}
}
</style>
</head>
<body>
    <div class="wrapper">
     <div class="slider">

        </div>
    </div>
</body>
</html>

Thursday, 19 March 2015

Login Page Using HTML and CSS


Copy and paste this code to get the above output

CSS code
*
{
	margin:auto;
}
.wrapper
{
	background:#B7D0D1;
	width:960px;
	height:800px;
}
.login
{
	float:left;
	margin:130px 0px 0px 250px;
	
}
fieldset
{
	width:400px;
	border-radius:5px;
}
form
{
	padding:20px;
	margin-left:20px;
}
input
{
	width:80%;
	height:30px;
	border-radius:5px;
}
#btn
{
	background:#D4282B;
	color:#263787;
	font-size:22px;
	font-weight:bold;
	font-family:Lucida Bright;
}
#btn:hover
{
	background:#ECB958;
	cursor:pointer;
}

Dropdown Navigation Menu Using HTML and CSS


This is the HTML code, just copy and paste this code to get the drop down menu

CSS Code
* 
{
 margin:auto;
}

.nav 
{ 
 width:1000px;
    height:30px;
 padding:0px; 
 background-color: #663300;

}

.nav ul
{ 
 padding:0px; 
 margin:0px; 
 line-height:30px;
}

.nav li
{   
 list-style:none;
    float:left; 
    position:relative;
}

.nav a 
{ 
 width:130px;
    height:30px;
 text-decoration:none;
 display:inline-block;
 text-align:center;
 background-color: #663300;
 color:#000;
 margin-left:20px;
 border-radius: 0px 0px 10px 10px;
}
.nav ul ul
{ 
 position:absolute; 
 visibility:hidden 
}

.nav li:hover ul
{ 
 visibility:visible;
}
.nav a:hover 
{
 background-color: #66FF00;
}     
       

Wednesday, 28 January 2015

How to create a drop down menu in HTML and CSS


copy and paste this code in your text editor to see the output.

CSS code
#menu{
position:absolute;
top:150px;
left:8%;
padding:0;
margin:0;
}
#menu ul{
padding:0;
margin:0;
line-height:30px;
}
#menu li{
position:relative;
float:left;
list-style:none;
background:rgba(0,0,0,1);
border-radius:5px;
}
#menu ul ul{
position:absolute;
visibility:hidden;
padding:0;
margin:0;
top:30px;
}
#menu ul li a{
text-align:center;
font:"Arial Black", Arial;
font-size:24px;
color:rgba(255,255,255,9);
width:150px;
height:30px;
display:block;
text-decoration:none;
}
#menu ul li:hover{
background-color:rgba(128,128,128,1);
text-decoration:none;
}
#menu ul li:hover ul{
visibility:visible;
z-index:1;
}
#menu ul li:hover ul li a{
background:rgba(0,0,0,9);
z-index:1;
border-bottom:1px solid rgba(160,160,164,1);
opacity:0.9;
text-decoration:none;
border-radius:5px;
}
#menu ul li ul li:hover{
background:rgba(128,128,128,1);
opacity:0.8;
text-decoration:underline;
}