On the website airbnb, there is a "play" button on the homepage that, when clicked, activates a fullscreen HTML video.
Is it possible to design a button or function that can automatically trigger a full-screen HTML video?
On the website airbnb, there is a "play" button on the homepage that, when clicked, activates a fullscreen HTML video.
Is it possible to design a button or function that can automatically trigger a full-screen HTML video?
After exploring the Airbnb website, I came across the video feature that matches what you described. It seems like you are looking for a lightbox with a video component. Achieving this effect is quite simple. Here's what you will need:
A clickable button.
A div
to serve as the lightbox, which only appears after clicking the button.
An additional div
where the video will be embedded.
The actual video content to display.
A close button for shutting down the lightbox.
I have created a basic version of this setup for you on this codepen.
You can also experience it firsthand by using the code snippet provided below.
$(document).ready(function() {
// Clicking the button fades in the lightbox in 1 second, hides the button, and starts playing the video
$("#button").on("click", function() {
$("#lightbox").fadeIn(1000);
$(this).hide();
// Quick hack to autoplay the video without the YouTube API
var videoURL = $('#video').prop('src');
videoURL += "?autoplay=1";
$('#video').prop('src', videoURL);
});
// Clicking the close button fades out the lightbox in 0.5 seconds and shows the play button
$("#close-btn").on("click", function() {
$("#lightbox").fadeOut(500);
$("#button").show(250);
});
});
#button {
/* Text */
font-size: 45px;
/* Dimensions */
width: 100px;
height: 100px;
/* Positioning */
position: fixed;
top: 50%;
left: 50%;
z-index: 2;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
/* Center the button vertically and horizontally on the screen */
/* Styling */
background-color: rgba(0, 0, 0, 0.95);
border: 0; /* Remove default grey border */
border-radius: 50%; /* Shape it into a circle */
outline: none; /* Eliminate blue click outline */
cursor: pointer;
box-shadow: 0px 0px 0px 2px rgba(0, 0, 0, 0.25);
/* Scale transformations */
-webkit-transform: scale(1, 1);
-moz-transform: scale(1, 1);
-ms-transform: scale(1, 1);
-o-transform: scale(1, 1);
transform: scale(1, 1);
/* Hover effects */
-webkit-transition: transform .5s ease;
-moz-transition: transform .5s ease;
-ms-transition: transform .5s ease;
-o-transition: transform .5s ease;
transition: transform .5s ease;
}
#button:hover {
/* Hover scaling */
-webkit-transform: scale(1.2, 1.2);
-moz-transform: scale(1.2, 1.2);
-ms-transform: scale(1.2, 1.2);
-o-transform: scale(1.2, 1.2);
transform: scale(1.2, 1.2);
/* Transform transitions */
-webkit-transition: transform .5s ease;
-moz-transition: transform .5s ease;
-ms-transition: transform .5s ease;
-o-transition: transform .5s ease;
transition: transform .5s ease;
}
#button > i {
/* Text */
color: grey;
text-shadow: 1px 1px rgba(255, 255, 255, 0.2);
/* Play sign positioning */
position: relative;
margin-top: 4px;
margin-left: 6px;
/* Transition effects */
-webkit-transition: color .5s ease;
-moz-transition: color .5s ease;
-ms-transition: color .5s ease;
-o-transition: color .5s ease;
transition: color .5s ease;
}
#button:hover > i {
/* Text color change on hover */
color: white;
/* Transition settings */
-webkit-transition: color .5s ease;
-moz-transition: color .5s ease;
-ms-transition: color .5s ease;
-o-transition: color .5s ease;
transition: color .5s ease;
/* Make the play sign white on hover */
}
#lightbox {
/* Positioning */
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
/* Covers the entire page */
/* Style */
display: none;
background-color: rgba(0, 0, 0, 0.95);
/* Typical lightbox has around 90-95% opacity allowing some visibility behind it */
}
#video-wrapper {
/* Centralize video */
position: absolute;
top: 50%;
left: 50%;
z-index: 2;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
/* Add shadow for better blend */
box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.1);
}
#close-btn {
/* Button style */
color: grey;
font-size: 25px;
/* Position */
position: fixed;
top: 3%;
right: 3%;
z-index: 2;
/* Top-right corner placement */
/* Initial scale setting for button transition */
-webkit-transform: scale(1, 1);
-moz-transform: scale(1, 1);
-ms-transform: scale(1, 1);
-o-transform: scale(1, 1);
transform: scale(1, 1);
/* Button transition effects */
-webkit-transition: transform .5s ease, color .5s ease;
-moz-transition: transform .5s ease, color .5s ease;
-ms-transition: transform .5s ease, color .5s ease;
-o-transition: transform .5s ease, color .5s ease;
transition: transform .5s ease, color .5s ease;
}
#close-btn:hover {
/* Text color change on hover */
color: white;
/* Visual cue for clickability */
cursor: pointer;
/* Scale-up on hover */
-webkit-transform: scale(1.2, 1.2);
-moz-transform: scale(1.2, 1.2);
-ms-transform: scale(1.2, 1.2);
-o-transform: scale(1.2, 1.2);
transform: scale(1.2, 1.2);
/* Hover transitions */
-webkit-transition: transform .5s ease, color .5s ease;
-moz-transition: transform .5s ease, color .5s ease;
-ms-transition: transform .5s ease, color .5s ease;
-o-transition: transform .5s ease, color .5s ease;
transition: transform .5s ease, color .5s ease;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!--Dependencies-->
<!--Include latest Font Awesome CSS for the close button.
Get it here: https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css-->
<!--Make sure to include the most recent jQuery library
for the script functionality
Link: http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js-->
<button id="button"><i class="fa fa-play" aria-hidden="true"></i>
</button>
<div id="lightbox">
<i id="close-btn" class="fa fa-times"></i>
<div id="video-wrapper">
<iframe id="video" width="960" height="540" src="https://www.youtube.com/embed/lJfqK9bgIng" frameborder="0" allowfullscreen></iframe>
</div>
</div>
Hey there! I'm currently working on making an HTTP request using the callback method, but I'm encountering an issue where I'm receiving a lot of information, but not the specific data I need: Request { domain: null, _events: { e ...
I am working with a String that contains e-mail content, and my goal is to eliminate all HTML coding from this String. This is the current code I have: public static String html2text(String html) { Document document = Jsoup.parse(html); document = ...
I have a contenteditable div where I am facing an issue with pasting text. Whenever I try to paste some text into the div, it always gets pasted at the end. I am using ViewChild to access the reference of the contenteditable div and utilizing innerText to ...
I've been searching for an official answer to this question, but it seems there is some confusion. Some people consider DOM objects to be JS objects, while others argue that they are different entities. What is the correct answer? If you search on Sta ...
Is there a way to automatically populate these two input fields without any manual input? <input type="time" name="Time" id="Time" value="" /> I am looking for a solution to automatically fill the date and ti ...
I'm attempting to swap out an object3D for a character model, while retaining all of its attributes like the position. var object = new THREE.Object3D( ); object = models.character[0].clone( ); object.position.set( 100, 230, 15 ); scene.add( object.sc ...
My approach to date selection involves using 3 mat-select components for day, month, and year. You can view a demo of this setup here. In an attempt to improve the code, I decided to set the initial options as null by modifying the following lines: allDat ...
Given an array arr[8,4,2,1,7,5,3,0] containing 8 elements, I am looking for a way to randomly select each number from the array without any repeats. The goal is to ensure that every number is picked exactly once. ...
Seeking a method to create a collapsible left side panel without affecting any other elements on the website. Preferably with a smooth sliding animation instead of an abrupt pop-in and out effect. Check out my website here to see the panel in question You ...
I am looking for a way to trigger a function call within a response so that I can open a modal. Currently, I am utilizing Material UI for the modal functionality. Learn more about Modals here The process involves: Clicking on a button Sending a request ...
I stumbled upon this template: . I am facing an issue where the second div I added does not display the dates, months, and years when duplicated. Here's a snippet of the script: <div class="form-date"> <label for="birth_dat ...
Currently, I am working on an angularJS application where I retrieve data from a REST service within the controller. The retrieved data is then passed to the view using $scope. However, I encountered an issue when trying to use this data in my in-page Java ...
Trying to create a container with two columns, each containing two columns of their own, all with equal heights using only CSS. The issue: the inner columns in their parent column do not align with the other inner columns in their respective parent column ...
Is it possible to download attached files using Paperclip without relying on external libraries? I want to enable users to download the file immediately after uploading, before it reaches the backend. I managed to achieve this using file-saver But I&apo ...
Is there a way to populate HTML form input fields with JSON data retrieved from an API? I have successfully displayed the data in a table using the code below, but I am struggling to make it work with a form. I have tried various approaches like <input& ...
Having trouble parsing the following JSON output using jQuery. The issue arises when trying to parse the "pprice" value, resulting in an "undefined" error. { "response": [ {"instances": [ { "instanceID": "000001", "instanceOS": "FreeBSD", "instanceVersion ...
I am working on developing a tool to extract data from the Wikipedia API. Within an XML file named wikiepedia.html, I have several links that I want to parse through line by line in order to retrieve information which can then be formatted into JSON. The ...
Presently, I have implemented a search bar that is connected to my search results through the following code snippet: render() { if (this.props.itemsFetchSuccess) { return ( <Redirect to={{ pathname: '/search', search: `?ite ...
Is there a way to ensure that the link stays contained within the div element and does not extend beyond it? It seems like the padding is causing an issue where the div considers the link to be as tall as the text. Any solutions or workarounds? Check out ...
I've attempted to execute the following code, which is supposedly the simplest example of Vue.js, but it doesn't seem to be working: <div id="app"> {{ message }} </div> <script> var app = new Vue({ el: '#app', d ...