Ways to resize video display based on window dimensions?

I am struggling with creating a two-column row where one column retains its height and size regardless of the window size, while the other should adjust to shrink or stretch based on the window size. Unfortunately, my CSS skills are still at a beginner level, so I haven't been able to figure it out by reading similar answers.

Here is the code snippet I have:

<div class="row upper-row">
  <div class="text-column">
    <!-- some text here -->
  </div>
  <div class="video-column">
    <div class="video">
      <video controls>
        <source src="<some source>" type="video/mp4">
      </video>
    </div>
  </div>
</div>

My attempt at using CSS to achieve this has not been successful despite trying techniques like fit-content, object-fit, and flexbox. Here is what I have so far:

.text-column {
  width: 500px;
}

.video-column {
  min-width: 500px;
}

UPDATE

After experimenting with Bootstrap's auto-layout columns, I have found a solution that seems to work. However, I am facing an issue where the page doesn't overflow once the video reaches its minimum width and instead wraps into a second row. This is the updated HTML and CSS:

<div class="container">
    <div class="row upper-row">
        <div class="col-lg-auto text-column">
        <!-- some text here -->
        </div>
        <div class="col video-column">
            <div class="player-container">
                <div class="video">
                    <video controls>
                        <source src="<some source>" type="video/mp4">
                    </video>
                </div>
            </div>
        </div>
    </div>
</div>

CSS:


.player-container {
    width: 90%;
    height: 100%;
    position: relative;
    top: 5%;
    left: 4%;
}

.video {
    position: absolute;
    top: 0%;
    left: 0%;
}

video {
    min-width: 10%;
    max-width: 100%;
    min-height: 10%;
    max-height: 100%;
}

With this setup, the text column retains its width while the video column adjusts according to the window size. However, I am still working on resolving the overflow issue after reaching the minimum width for the video column.

Answer №1

To create a responsive design, consider either incorporating media queries into your CSS or setting the container's dimensions to width:auto and height:auto.

Answer №2

When it comes to creating a two-column layout, there are numerous methods to choose from. In my view, using flex is the most straightforward solution.

Check out the Codepen solution here

Nevertheless, I wouldn't recommend this approach due to its lack of responsiveness. It doesn't adapt well to different screen sizes and is not ideal for mobile devices.

To create a more effective layout, consider spanning both columns across the entire width of the screen and adjusting the size of the video element accordingly.

Explore a better solution on Codepen

You could also achieve this with a Grid layout instead of Flex.

Here is a helpful guide on implementing common layouts using CSS grid.

Answer №3

To enhance the adaptability of your video, consider utilizing the percentage sign (%)

.video-container video { width: 100%; }

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

The header of the data table does not adapt well to different screen

I am currently experiencing an issue with my Angular data table. Everything works fine until I add the option parameter "scrollY: '200px'" or "scrollY: '50vh'", which causes a bug in my table header. It becomes unresponsive, and the siz ...

Performing calculations using jQuery and organizing sub-totals into groups

I am currently developing a web application and aiming to incorporate an invoice calculation feature with sub-groups. My goal is to have the total result of both group-totals and sub-totals at the end. Here is my progress so far: Check it out here $(func ...

Retrieve HTML content from a JSON object and render it on a web page

I am facing a challenge with decoding html that is in json format. I'm struggling to figure out how to retrieve my html and display it on a page. It seems like json_decode isn't the solution. Can anyone help me with this issue? Appreciate any as ...

What causes the content of a sticky navbar to overflow?

I have a situation where my navbar has two styles (.navbar and .navbar_fixed), but the links in the navbar are not fitting properly. I attempted to remove padding and add left: 0;, however, these adjustments did not work as expected. Any suggestions on how ...

Display the child elements in an HTML document that have the same class name as the parent element, while concealing all

<div class="element-2"> <div class="element-1"> <p>div 1</p> </div> <div class="element-2"> <p>div 2</p> </div> </div> The main objective is to display only child divs with sim ...

Code snippets to reduce excess white space on a website using HTML and CSS

On my website, there are multiple tabs, each containing content from an HTML file. When a user clicks on Tab1, boxes with images are displayed. The layout can be seen in the following Code Demo: Code Demo here There seems to be extra space before and afte ...

After clicking the 'add row' button, I successfully added a new row; however, the jQuery date

I encountered an issue with the datepicker when adding it to dynamically added rows. The datepicker was not functioning properly on the added rows, except for the first row where it worked perfectly. Strangely, removing the first row resulted in the datepi ...

Design an HTML button/label with text and a starting width of zero

I'm attempting to design HTML buttons and labels with text that initially have zero width. Once inserted, they should smoothly transition to a visible state. I've tried adjusting the initial width and min-width style properties without success. ...

What are the steps to effectively utilize the static folder in Django for organizing CSS and JavaScript files?

I'm completely new to the Django framework. I managed to create a simple welcome page, but now I'm struggling to include a CSS file in my project. Whenever I try to apply the CSS file, I encounter an error saying "NetworkError: 404 NOT FOUND - / ...

How to align text to the left and right within a Bootstrap accordion

I am currently working on a Bootstrap accordion, and I have a specific layout in mind. I want to display text on both the left and right sides of the accordion header, right next to the arrow that expands and collapses the content: https://i.sstatic.net/d ...

Using the linearGradient feature within an SVG to create a transitional effect on the Fill property

Looking to implement a stepper functionality, everything is working smoothly except for the transition on the fill. let step = 0; document.querySelector("button").addEventListener('click', () => { step++; document.querySelector("svg ...

aligning a floating image vertically

One issue I am facing in my UI is that I have buttons with images floating next to text. While the setup works well, I am struggling to vertically align the image with the text. I've experimented with various solutions including using vertical-align: ...

An illustration using Bootstrap 5: Cover page design featuring a fixed-top navigation bar and smoothly scrolling content

Struggling with customizing the bootstrap 5 cover page example. I really love the design, especially the header and footer (without toggle, brand staying on a single line, etc.). Want a page with more content scrolling in the middle, while keeping the nav ...

I am looking to implement a feature in my quiz application where a green tick mark appears next to the question number for the correct answer and a red cross mark for the wrong answer

My HTML code here retrieves questions from a database and displays them based on the question number. <h4>{{indexOfelement+1}}</h4>&nbsp;&nbsp; In my CSS, I need to style the questions as follows: How can I achieve this? Each question ...

Encountering an error when utilizing Angular Animation with Bootstrap -> Issue arises from attempting to read properties of undefined (specifically 'box-sizing')

To access the source code of Git, visit https://github.com/codezj/exampleAppAnimation. I recently developed a method to extract Bootstrap CSS and utilize it as CSS in Angular. However, I encountered an error while running the Angular project: Uncaught Typ ...

What steps are involved in customizing the footer section of a

I'm trying to track down a piece of html that seems to be triggering random black boxes appearing on my website pages. It looks like there might be a duplicated footer section, and <footer></footer> could be the culprit. I'm not sure ...

`Implementing Bootstrap grid system within a PHP loop`

I am currently working on a project that involves extracting data from a database and displaying it on an HTML page using Bootstrap grids. The code snippet below was given to me by someone, and I have made a few modifications by adding two tags: and . How ...

How to stop the overflow scrollbar in a grandchild element with CSS grid

Encountered an unusual issue while using a combination of CSS grid and overflow auto. In the scenario where there are 3 elements, the outermost element has display: grid, the middle element has height: 100%, and the innermost element has both height: 100% ...

What's the reason behind the presence of the a tag before the button in this

While working with Bootstrap 4, I noticed that the a tag is being displayed before the button when using the following code. Can anyone explain why? <button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#navbar ...

Tips for creating unique title descriptions for identical files to prevent repeating content

Essentially, Google considers www.example/cz and example.cz/index.php as duplicate content because they share the same meta descriptions. It's important that example.com/cz and example.com/cz/index have unique meta descriptions to avoid this issue. I ...