What is the best method for adjusting the size of a button on a video as needed?

@import url("https://fonts.googleapis.com/css2?family=Luxurious+Script&display=swap");
* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  font-family: "Luxurious Script", cursive;
}

body {
  background-color: #e97272;
}

.navbar {
  background-color: rgb(83, 83, 83, 0.2);
  width: 100%;
  height: 140px;
}

.nav-brand {
  margin-left: 40px;
  margin-top: 20px;
  height: 100px;
  display: inline-block;
}

.nav-brand img {
  width: 100%;
  height: 100%;
}

.nav-items {
  display: inline-block;
  margin-left: calc(100% - 900px);
  font-size: 2.5rem;
  vertical-align: bottom;
  text-shadow: 2px 2px #514d4d;
  color: rgb(236, 200, 0);
}

.items {
  margin: 20px 50px;
  display: inline-block;
}

.items a {
  text-decoration: none;
  color: inherit;
}

.Video-Greeting {
  position: relative;
  width: 75%;
  margin: 0 auto;
}

.Video-Greeting video {
  width: 100%;
}

.Video-Greeting button {
  position: absolute;
  top: 30%;
  left: 40%;
  margin: 0 auto;
  color: rgb(236, 200, 0);
  text-shadow: 3px 3px #514d4d;
  font-size: 4em;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="Home.css" />
  <title>Welcome</title>
</head>

<body>
  <nav class="navbar">
    <div class="nav-brand">
      <img src="image\Logo.png" alt="" />
    </div>
    <ol class="nav-items">
      <li class="items"><a href="">Home</a></li>
      <li class="items"><a href="">Place Order</a></li>
      <li class="items"><a href="">About</a></li>
    </ol>
  </nav>

  <div class="Video-Greeting">
    <video autoplay loop muted src="image\Pexels Videos 2706078.mp4"></video>
    <button>Welcome</button>
  </div>
</body>

</html>

I am facing an issue with my Welcome Button in my video, as it is not staying centered and scaled properly when I resize the browser window. I want the button to remain at the center of the video and scale proportionally as the browser size changes. How can I achieve this without the button drifting off-center?

Answer №1

To style the .Video-Greeting section, include the following CSS properties:

display: flex;
justify-content: center;
align-items: center;

These properties will center all content such as <button> and <video> both vertically and horizontally.

Additionally, add the following CSS property for the button:

z-index: 1;

Setting the z-index property allows the button to be positioned above other elements, creating a sense of depth.

Make sure to remove the top and left properties from the <button> as well.

Finally, the provided CSS code snippet includes styles for various elements like the navbar, font styles, and layout properties. It also defines the structure of the HTML document with a navigation bar, greeting section with a video and button, and a footer.

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

Tips on utilizing jQuery or JavaScript to efficiently filter out outcomes exceeding a specified range

<input type="range" name="rangeInput" min="100000" max="750000" onchange="updateTextInput(this.value);"> Displayed above is the slider code that provides a value output below. <div id="sliderValue"> <p>Max Value £</p> <input t ...

Step-by-step guide on how to superimpose a Glyphicon on

I'm struggling to figure out how to overlay a Glyphicon (.glyphicon-zoom-in) on top of a Bootstrap .img-thumbnail. The specific CSS rule I've been using is content:"\e015"; ...

It is recommended that the page does not scroll while utilizing both the sidenav and toolbar simultaneously in Angular Material

Using md-sidenav without md-toolbar works fine. The sidenav opens correctly, as shown in the image below. https://i.sstatic.net/PjsPp.png However, when a toolbar is added before the sidenav or its containing section, opening the sidenav causes the page t ...

The standard jQuery Mobile CSS styling does not seem to be working across various browsers, extensive testing has been conducted

I'm currently experimenting with jQuery Mobile to enhance my skills, but I'm facing issues with applying the basic CSS styling. I have included the css link from the jQuery Mobile website and ensured that I am connected to the internet. However, ...

Dealing with CSS Overflow Issues: Fixing the Scroll Bug

My current project involves creating a page with fixed links at the top and submit buttons at the bottom. The content in the middle is scrollable using overflow:auto. I've noticed that when I resize the browser window, the scrollbar slowly disappears ...

Attempting to create a child process within the renderer by triggering it with a button click

I'm currently developing an electron application where I am attempting to initiate a child node process (specifically to run a Discord.JS bot). Below is the code snippet in question: index.html: <tr> <th class="title-bar-cell" ...

Navbar Collapse in Bootstrap 5 not functioning properly when losing focus

I am working on a project as a beginner where I am coding a site navbar using Bootstrap 5. The issue I am facing is that currently, the navbar does not collapse when I click away after expanding it. My goal is to make it so that the navbar automatically co ...

The Bootstrap modal fails to open

I am currently working on implementing a Navbar button that triggers a Bootstrap modal containing a form. While looking for resources, I stumbled upon a useful script at https://gist.github.com/havvg/3226804. I'm in the process of customizing it to su ...

Managing Input Type Dropdown Selections Using Jquery

I am currently in the process of developing a website. On this website, there is a form that includes 3 dropdown menus as shown below. I would like to implement a feature where selecting the number 5 from the Adults menu will automatically display 5 in the ...

Ways to conceal dropdown div once an area outside its parent menu is clicked?

I've got this neat jQuery script that's working perfectly. It's a basic dropdown menu setup where clicking on the "topbar" element toggles the visibility of the "topbarin" div. $(document).ready(function(){ $('.topbar').click( ...

What is the best way to duplicate the table header?

I'm looking to have the table header repeat twice using ng-repeat, like this: a b | a b | Instead of aa | bb. Currently, my code only displays a b | <table class="table table-striped table-bordered"> <thead> ...

Extracting information from Mysql database and saving it in the option html element

Hi everyone, I'm facing a problem with a question. My goal is to fetch data from MYSQL and save it in an option tag. Below is my code snippet. <?php $user = "admin"; $password = ""; $db = "test"; $host = "localhost"; $cxn = mysqli_connect($host, $ ...

Concealing Components using Angular's ng-change Feature

I need help displaying or hiding an element in a form using ng-change or any other method you suggest. Here is the HTML snippet I am working with: <div ng-app ng-controller="Controller"> <select ng-model="myDropDown" ng-change="changeState( ...

Pressing the button in the navigation bar results in an expansion of the navbar

Can someone help me figure out why my navbar's height is different from the example on this Bootstrap navigation bar snippet? Here's the code I used: https://www.w3schools.com/bootstrap4/tryit.asp?filename=trybs_navbar_form&stacked=h I copi ...

Executing JavaScript code only if certain date conditions are satisfied

I'm trying to come up with a way to execute a piece of JavaScript code when a specific date condition is met: For instance: Do not run the code if the date falls between June 6th, 2014 5PM CST and June 16th, 2014 5PM CST. Or maybe the opposite wou ...

A guide on extracting checkbox value from a database in PHP through the use of the explode function

I have a form with three checkboxes where some people select all subjects and others select only two. I need to retrieve the checkbox values from the database. Below is my current code. If anyone knows the solution, please share. <?php $connection = ...

Can you explain the distinction between the onclick(function(){}) and on('click',function(){}) functions in jQuery?

My goal is to dynamically load pages into a specific div using ajax. Here's my HTML code: <ul id="nav" class="nav" style="font-size:12px;"> <li><a href="#" id="m_blink">Tab1</a></li> <li><a href="#" id= ...

The Vanishing Act of Bulma Dropdowns in Vue Router

On regular pages, the dropdown feature functions flawlessly. However, when using Vue-router in a single-page application (SPA), the dropdown menu seems to vanish between the navbar-item and its child navbar-link unless the cursor is moved quickly from one ...

Whenever my code is used within Google Sites, it triggers the opening of a new and empty tab

When using this code inside an HTML box in Google Sites, a problem arises. It seems to work perfectly fine in Internet Explorer and Chrome when saved to an HTML file. However, within Google Sites, it unexpectedly opens a new tab with no data. The code st ...

Center a span vertically inside a div as the text within the span grows to occupy the entire div

I am facing an issue with a table that has 25 td's. Each td contains specific elements as shown below: <td> <div> <span> text </span> </div> </td> Additionally, there is a script in place that adj ...