Television Mount for Precise Video Placement

Seeking assistance for a unique positioning challenge I am facing.

I have a Video that needs to be placed on the home page with a TV-like image "frame" around it, and they should scale together.

https://i.sstatic.net/2pLhi.png

What I've attempted is removing the middle border, keeping the TV outline, creating a container, stretching the image to fill the entire container. However, I'm struggling to center the video because the container is smaller than the image.

HTML

<?php
get_header();
?>
<section class="Home-main">
    <div class="row">
        <div class="sidebar-space col-xs-0 col-sm-3 col-lg-2">

        </div>
        <div class="content col-xs-12 col-sm-9 col-lg-10">
            <div class="container">
                <div class="home-video">
                       <img class="h-video" src="<?php echo home_url();?>/wp-content/uploads/2020/06/Tv-Frame.png">
                    <iframe src="https://player.vimeo.com/video/427699658" width="640" height="480" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

                </div>
            </div>
        </div>  
    </div>
</section>

<?php
get_footer();
?>

CSS

.Home-main{
    background-image: url("http://localhost/Gummy-Vital/wp-content/uploads/2020/06/Home-back.png");
    height:4500px;
    background-repeat: no-repeat;
}

.home-video{
    position:relative;
    margin-top:40px;
}

.h-video{
    width:100%;
    height:auto;
        position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

Note: The exaggerated height is just to ensure the background aligns correctly.

I intend to add a border around the video for an inner border effect.

https://i.sstatic.net/ZlrKa.png

Answer №1

To accomplish this task, there are various methods you could utilize:

One option is to employ absolute positioning as you initially did:

.home-video{
  position:relative;
}

.h-video{
  position: absolute;
  width:100%;
  height:auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Alternatively, you could implement flexbox:

.home-video {
  display: flex;
  justify-content: center;
  align-items: center;
}

.h-video {
  width:100%;
  height:auto;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discover the secret to creating a seamless looping effect on text using CSS gradients, giving the illusion of an endless loop

Could use some assistance with looping this gradient smoothly over the text without any annoying jumps appearing during the animation. Is there a way to achieve a seamless movement across the text? Any suggestions on how to approach this? Here is a liv ...

The clash between CSS's 'snap-scroll' and jQuery's '.animate scrollLeft' functionality

My HTML and CSS slider utilizes the scroll-snap feature for manual scrolling along with jQuery buttons for automated scrolling. However, I have encountered an issue where using scroll-snap-type: x mandatory; causes severe lag in the jQuery scrollLeft anima ...

Can you align a row under its corresponding column in Bootstrap?

Hello, I'm facing a dilemma with my layout. I have a grid consisting of 2 Rows and 4 Columns (col-md-8 & col md-4 in each row). The structure is as follows: Within the container Row 1 Column 1 (md-8) Row 1 Column 2 (md-4) [Accordion] Row 2 Colum ...

Identifying the accurate folder for file uploads

In my project directory, I have a folder named uploads, along with two files called upload.html and upload.php. The relevant part of my upload.html file looks like this: $(document).ready(function(){ $("#pictureUploadSubmit").submit(function(event) { ...

Display a single video on an HTML page in sequential order

My webpage contains a video tag for playing online videos. Instead of just one, I have utilized two video tags. However, when attempting to play both videos simultaneously, they end up playing at the same time. I am seeking a solution where if I start pla ...

Currently experimenting with jQuery in conjunction with the reddit API to generate individual divs for every post

Issue with displaying post titles, URLs, and permalinks separately. Need them to display together for each post. See the code below: $(document).ready(function() { $.getJSON( "http://www.reddit.com/r/pics.json?jsonp=?", function foo(data) { ...

Python and Selenium are a powerful combination, but sometimes you may encounter the error message "Element cannot be clicked at point (x,y)

I'm trying to automate the selection of a checkbox on a webpage using Selenium and Python with this line of code: self.driver.find_element_by_id('lg_1166').click() Unfortunately, I'm encountering an error message: Message: Element < ...

HTML TABS: Make the first TAB automatically selected

I've been experimenting with tabbing in HTML using a tutorial I found on W3SCHOOLS. While the source code provided works fine, I'm encountering an issue with automatically selecting the first tab by default. The tutorial doesn't cover this, ...

Changing the text alignment to justify in OWA - HTML emails

Having trouble navigating the Outlook Web App (OWA)? It seems like there are countless issues with different Outlook clients, but OWA is definitely the most poorly documented one. The snippet of code below functions flawlessly in all email clients such as ...

Creating a default menu within a specific route in Ember.js is a crucial step in

I have created a JSBin code for my Ember.js application which can be found here: When I click on Item A, I want the ABCD menu on the left to remain visible and not disappear. Thank you. ...

Using Geolocation in HTML5 and JavaScript

Currently, I am working on my debut mobile web application and have successfully integrated Google Maps into it using Geolocation JavaScript API version 3. Now, I am looking to add a button that, when clicked by the user, centers the map on my location o ...

Formatting text and images in CSS

Looking to align images at the bottom of each column in a div with 3 columns, but struggling due to varying text lengths. Any tips on how to achieve this? https://i.sstatic.net/fuPgl.png Thank you, Carolin #content_row{ margin-top:150px; marg ...

Embracing right-to-left (RTL) languages

I am looking to create a website that can support both left-to-right (LTR) and right-to-left (RTL) languages seamlessly. My goal is to have the text direction switch automatically to RTL if the content is in an RTL language. Additionally, I want the input ...

Making a dropdown menu spin using Jquery and Javascript

I am in need of a unique solution for a dropdown menu that appears rotated 90 degrees anticlockwise. The goal is to have the dropdown select "button" text displayed vertically, with the options sliding out in a similarly rotated, sideways manner featuring ...

Concealing specific DIV elements (unfortunately not nested)

Currently, I am dealing with pre-existing code that is automatically generated and needs to adhere to a specific format: <div id="TITLE1"></div> <div id="div-1"></div> <div id="div-2"></div> <div id="div-3"></d ...

The issue of duplicate backgrounds appearing on the burger menu when adjusting the height

There seems to be an issue with my burgermenu; when I attempt to adjust the height, the background-color ends up duplicating. .bm-menu { background-color: rgba(255, 255, 255, 0.9); height: 60vh; position: fixed; transition: top 0.3s; to ...

A webpage specified with 'charset=iso-8859-1' accompanied by <!DOCTYPE HTML> is triggering a cautionary alert

After running the W3C validator on an HTML document, I discovered that using the following meta tag: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> in conjunction with: <!DOCTYPE HTML> results in ...

How can the 'selected' attribute be assigned to 'select/option' tags depending on the option value?

In my code, I have a select input with various options and values. I want to set the 'selected' attribute for the option that corresponds to a specific value X. Here is an example: // If x=3, I want the option with value=3 to be marked as 's ...

How to make browsers refresh cached images

.button { background: url(../Images/button.png); } Issue: To improve performance, static content on the website is cached with expiration headers. However, when an image changes, users must manually refresh their browser cache (Ctrl+F5 in IE). ...

No matter how tall I make it, the scroll bar just won't stop showing

Check out this fiddle for more information: http://jsfiddle.net/LAueQ/ Even after increasing the height of the campaignDiv div, the scrollbar keeps showing up. If possible, I would like to avoid using overflow: hidden. ...