Home » How to Create Responsive Movie Trailer Website using html, css, jquery

How to Create Responsive Movie Trailer Website using html, css, jquery

by admin
responsive Movie trailer website

If you want to download the source code then click here

This is the simple movie trailer showing website with responsive and this website homepage is creating only using html, css and jquery. first you will see the header part which is logo and right side menu, then next is main banner like hero section, when you click the play button to popup the video. then next is other movie trailer section like card section, next section is again card sectino after that subscribe or newsletter form section and last is footer, that’s the whole content of this website homepage.

<head>
	<title>Movie Trailer Website Homepage</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>

<!-- html goes here -->


<!-- JQUERY -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<script>
// SCRIPT WRITE HERE

</script>
</body>

Basic structure of HTML But I have attached the necessary links in it like custom styles, jquery, all these links I have attached.

<body>

<div class="wrapper">
	<div class="bgslide">
		<div class="nav">
			<div class="logo">
				<img src="images/logo.png">
			</div>
			<div class="mmenu">=</div>
			<div class="menu">
				<ul>
					<li><a href="#">NEW MOVIES</a></li>
					<li><a href="#">UPCOMING</a></li>
					<li><a href="#">REVIEWS</a></li>
					<li><a href="#">NEWS</a></li>
				</ul>
			</div>
		</div>

		<div class="play_button">
			<img src="images/play.png">
		</div>
	</div>

	<div class="movieposter">
		<h3>Popular Movies</h3>
		<hr>
		<div class="movie-trailer-grid">
			<div class="trailer1">
				<a href="#">
					<img src="images/a1.png">
				</a>
			</div>
			<div class="trailer1">
				<a href="#">
					<img src="images/a2.png">
				</a>
			</div>
			<div class="trailer1">
				<a href="#">
					<img src="images/a3.png">
				</a>
			</div>
			<div class="trailer1 trailer-last">
				<a href="#">
					<img src="images/a4.png">
				</a>
			</div>
		</div>
		<a href="#" class="viewall">View All</a>
	</div>


	<div class="movieposter">
		<h3>Must Watch</h3>
		<hr>
		<div class="movie-trailer-grid">
			<div class="trailer1">
				<a href="#">
					<img src="images/m1.png">
				</a>
			</div>
			<div class="trailer1">
				<a href="#">
					<img src="images/m2.png">
				</a>
			</div>
			<div class="trailer1">
				<a href="#">
					<img src="images/m3.png">
				</a>
			</div>
			<div class="trailer1 trailer-last">
				<a href="#">
					<img src="images/m4.png">
				</a>
			</div>
		</div>
		<a href="#" class="viewall">View All</a>
	</div>

	<div class="sub">
		<p>Get the best Movies trailers straight in your <br>inbox each week</p>
		<form class="myform" method="post" action="">
			<input type="email" name="" class="email" placeholder="Email Address" required="">
			<input type="submit" name="" class="submit" value="Subscribe">
		</form>
	</div>

	<div class="footer">
		<h1><b>WATCH</b>TRAILER</h1>
		<p>2018 MovieStuff | All Right Reserved</p>
		<p>Privacy Policy</p>
	</div>

</div>

<!-- Video Modal -->
<div class="video_modal">
	<div class="closebtn">X</div>
	<video id="myvideo" width="80%" height="auto" controls autoplay="">
		<source src="video/earth_zoom_in.mp4" type="video/mp4">
		<source src="video/earth_zoom_in.mp4" type="video/ogg">
	</video>
</div>

Above I have added the structure of HTML. First you will see the header and hero banner section which is the play button is there and background images or movie posters something like that. then next section is card section four cards in one row and next section is same card section, and next section is newsletter section after that footer. If you copy the HTML structure, then you do not need to add the links because I have already added the HTML structure.

Below I have put a link to more useful videos, which you will get to learn a lot from them, then you guys must watch them and if you like them, then definitely write them.

Also, I will add the HTML structure of the layout below, in which I have taken a tag named main, and inside it, I have created the structure of the whole layout. and also added two extra dives named cursor and cursor-back because I’m customizing a cursor style. and the next part is the top menu, then the hero section content, and after that bottom menu. 

	$(document).ready(function(){
		var $playbtn = $(".play_button"),
		$openvid = $(".video_modal"),
		$closevid = $(".closebtn"),
		$video = $("#myvideo").get(0);

		$playbtn.click(function(){
			$openvid.fadeIn();
			$video.load();
		});

		$closevid.click(function(){
			$openvid.fadeOut();
		});

		$(".mmenu").click(function(){
			$("body").toggleClass("bodyFix");
			$(".menu").toggleClass("menuFix");
		});
	});

As you can see from the above code, I am using jquery code, first, I created various variables for the play button, video model, close button, and my video. and i create a click function for play button inside the jquery fadein function and load functions. and next is click function for close video inside the jquery fadeout function. and next menu click function inside the toggle class for body and menu both.  

*{
	margin: 0;
	padding: 0;
}
html,body{
	font-size: 14px;
	color: #333;
	height: 100%;
}
.wrapper{
	background-color: #000;
	width: 100%;
	height: auto;
	min-height: 300px;
	display: inline-block;
	position: relative;
}
.bgslide{
	background-image: url(../images/bg.png);
	background-size: cover;
	background-position: center;
	width: 100%;
	height: 100%;
	min-height: 650px;
	float: left;
	position: relative;
}
.nav{
	padding: 35px 35px;
}
.logo{
	width: 150px;
	height: auto;
	display: inline-block;
	float: left;
}
img{
	width: 100%;
}
.menu{
	width: auto;
	height: auto;
	display: inline-block;
	float: right;
}
.menu ul li{
	list-style-type: none;
	display: inline-block;
	padding: 0 35px;
}
.menu ul li a{
	color: #fff;
	text-decoration: none;
	font-family: open sans;
	font-size: 18px;
	-webkit-transition: all ease 0.4s;
	-moz-transition: all ease 0.4s;
}
.menu ul li a:hover{
	color: yellow;
}
.play_button{
	width: 100px;
	height: auto;
	position: absolute;
	top: 50%;
	left: 50%;
	cursor: pointer;
	-webkit-transition: all ease 0.4s;
	-moz-transition: all ease 0.4s;
	-webkit-transform: translate(-50%, -50%);
	-moz-transform: translate(-50%, -50%);
}
.play_button:hover{
	width: 115px;
}

.video_modal{
	width: 100%;
	height: auto;
	/*border: 5px solid #fff;*/
	position: absolute;
	top: 50%;
	left: 50%;
	-webkit-transform: translate(-50%, -50%);
	-moz-transform: translate(-50%, -50%);
	display: none;
}
.video_modal video{
	position: absolute;
	z-index: 50;
	top: 50%;
	left: 50%;
	-webkit-transform: translate(-50%, -50%);
	-moz-transform: translate(-50%, -50%);
}
.closebtn{
	font-family: open sans;
	font-weight: bolder;
	width: 30px;
	height: 30px;
	border-radius: 60px;
	background-color: yellow;
	color: #000;
	text-align: center;
	line-height: 30px;
	position: absolute;
	top: 3%;
	right: 5%;
	cursor: pointer;
	z-index: 1000;
}

.movieposter{
	display: inline-block;
	/*width: 100%;*/
	float: left;
	padding: 60px 35px 10px;
}
.movieposter h3{
	font-family: open sans;
	font-size: 28px;
	color: #fff;
	font-weight: normal;
	padding-bottom: 8px;
}
.movieposter hr{
	background-color: #fff;
	border: none;
	height: 1px;
	width: 100%;
}
.movie-trailer-grid{
	padding: 30px 0px;
}
.trailer1{
	width: 24%;
	height: auto;
	margin-right: 16px;
	float: left;
}
.trailer-last{
	margin-right: 0px;
}
.viewall{
	display: inline-block;
	float: right;
	padding: 7px 35px;
	background-color: #262626;
	color: #fff;
	border-radius: 5px;
	text-decoration: none;
	font-family: open sans;
	font-size: 18px;
	margin-top: 15px;
}
.viewall:hover{
	background-color: #fff;
	color: #000;
}

.sub{
	width: 100%;	
	display: inline-block;
	padding: 155px 0px;
	background-image: url(../images/sub.png);
	background-repeat: no-repeat;
	background-size: cover;
	background-position: center;
	text-align: center;
	margin-top: 35px;
}
.sub p{
	color: #fff;
	font-family: calibri;
	font-size: 24px;
	text-align: center;
}
.myform{
	margin-top: 20px;
}
.sub .email{
	height: 35px;
	border: 1px solid #948691;
	background-color: rgba(255,255,255,0.1);
	color: #fff;
	border-radius: 7px;
	padding: 0 7px;
	width: 310px;
}
.sub .submit{
	height: 35px;
	background-color: rgba(255,255,255,0.255);
	border: 1px solid #fff;
	text-align: center;
	line-height: 33px;
	font-weight: bold;
	color: #fff;
	padding: 0px 25px;
	border-radius: 7px;
}

.footer{
	width: 100%;
	height: auto;
	padding: 25px 0px;
	text-align: center;
}
.footer h1{
	font-family: calibri;
	font-weight: normal;
	color: #fff;
}
.footer h1 b{
	font-weight: 700;
	margin-right: 5px;
}
.footer p{
	font-family: calibri;
	color: #fff;
	font-size: 18px;
	padding: 5px 0;
}

.menu,.mmenu{
	display: none;
}
.bodyFix{
	position: fixed;
}

I have added the css for style.css file. first i am writing basic css reset property then i’ll start main style. then you will see wrapper, bgslider styles. bgslider property is background image, position, height and width all those property is there. then navigation menu styles, play button class style with transform and transition effect when you hover a button for smothness. after video popup style when you click paly button to show the popup model, which is you can add embed video link or self server uploaded video. then movie poster like card section styles and newsletter form section and last footer section style.

@media only screen and (max-width: 1024px){
	.menuFix{
		display: block;
		position: fixed;
		width: 250px;
		height: 100%;
		background-color: #000000;
		top: 0;
		left: 0;
		z-index: 1000;
	}
	.menu ul li{
		width: 100%;
		padding: 30px 0 30px;
		text-align: center;
		border-bottom: 1px solid #ffffff30; 
	}
	.mmenu{
		display: block;
		position: absolute;
	    right: 35px;
	    top: 25px;
	    color: #000;
	    cursor: pointer;
	    font-size: 2em;
	    padding: 0px 10px;
	    background: #fff;
	    font-weight: 900;
		transition: 300ms;
	}
	.trailer1{
		width: 48%;
		margin-bottom: 10px;
		margin-right: 0;
	}
	.trailer1:nth-child(2n+1){
		float: right;
	}
}
@media only screen and (max-width: 480px){
	.trailer1{
		width: 100%;
		margin-bottom: 10px;
	}
}
@media only screen and (min-width: 1024px){
	.menu{
		display: block;
	}
}

I have given the above CSS code for responsive media, you can see the media query(media-only screen and max-width:1024) and device width, so basically when you resize the browser or you can open the website on a tablet or relevant device, the CSS property is working otherwise won’t work for particular device/sizes. and the same thing is going on but only width/size is change depend on the device ratio/pixel/size.

I hope you enjoyed this tutorial and you must have got to learn something new. So you must share it and subscribe to my LearnDesign youtube channel so that you can get the updates of my upcoming videos. thanks for your time.

Related Articles