Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video Conferencing like video grid using css grid

I am trying to create a video conferencing like grid. I am trying using css-grid but somehow I am not being able to accomplish what I am looking for. The idea is simple, have a grid of videos on screen and paginate the videos to next page which doesn't fit in the first.

I tried using the following:

<div className="videoContainer">
    <div className="videoWrapper">Cam 1</div>
    <div className="videoWrapper">Cam 2</div>
    <div className="videoWrapper">Cam 3</div>  
</div>

CSS

.videoContainer {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    border: 2px solid blue;
}
.videoWrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    border: 1px solid green;
}

What I am looking for is some pointers/ hints/ any articles(didn't find anything useful) that point to the direction I want to go.

I have a simple layout as follows to explain (Left column for large screen devices, right column for mobile devices):

enter image description here

like image 802
Ayan Avatar asked May 02 '20 16:05

Ayan


People also ask

What are CSS grids used for?

CSS Grid Layout excels at dividing a page into major regions or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives. Like tables, grid layout enables an author to align elements into columns and rows.

How do you make a grid system in CSS?

To make an element into a grid container, we need to use either the display: grid; or the display: inline-grid; property. The former results in a block-level grid, while the latter leads to an inline-level grid. In the CSS, we use the display: grid; property on the . container element to create a block-level CSS Grid.

Can you nest grids in CSS?

You can "nest" grids by making a grid item a grid container. These grids however are independent of the parent grid and of each other, meaning that they do not take their track sizing from the parent grid. This makes it difficult to line nested grid items up with the main grid.

What is CSS grid layout?

Grid Layout The CSS Grid Layout Module offers a grid-based layout system, with rows and columns, making it easier to design web pages without having to use floats and positioning.

What is a grid container in HTML?

An HTML element becomes a grid container when its display property is set to grid or inline-grid. All direct children of the grid container automatically become grid items. The vertical lines of grid items are called columns.

How do you create a grid in HTML?

An HTML element becomes a grid container when its display property is set to grid or inline-grid. All direct children of the grid container automatically become grid items. The vertical lines of grid items are called columns. The horizontal lines of grid items are called rows.

What is the difference between grid-row-gap and grid-column-gap?

The horizontal lines of grid items are called rows. The spaces between each column/row are called gaps. The grid-column-gap property sets the gap between the columns: The grid-row-gap property sets the gap between the rows:


Video Answer


1 Answers

I do not recommend using widths and heights with percentages. The important thing here is to respect the aspec ratio.

enter image description here

Example:

https://alicunde.github.io/Videoconference-Dish-CSS-JS/

Code:

https://github.com/Alicunde/Videoconference-Dish-CSS-JS

I have solved this problem today. First I started using CSS3 Grid, but the result did not respect the aspect ratio of the cameras.

Then I tried Flex, but it is not possible to cover defined surfaces. So I have created this pretty basic script.

The rest of the screens you need are easy to develop.

Phone version:

enter image description here

It is fast (resize event, load event):

enter image description here

Excuse my English.

like image 167
Salvatore Avatar answered Oct 20 '22 00:10

Salvatore