In the center of my webpage I have a div with id center-container which contains 2 divs: one for a video player(on the left) and the second one (on the right) for an optional thing like playlist. Above and below the center-container div I have another content as well.
Now the question. How can I make my video player container to come to the middle of the page when the playlist div is absent (not set) without braking the remaining layout.
Approach: To create a two-column layout, first we create a <div> element with property display: flex, it makes that a div flexbox and then add flex-direction: row, to make the layout column-wise. Then add the required div inside the above div with require width and they all will come as columns.
Three or more different div can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side.
An HTML column is defined in the <div> tag using the class = "column" keyword. More columns can be added by adding more divs with the same class. The following syntax is used to add columns in HTML. <div class="row"> tag is used to initialize the row where all the columns will be added.
You can do this with less & simple code like this:
.playlist{
width:100px;
height:100px;
float:right;
background:blue;
margin-right:20px;
}
.playlist + .video{
width:200px;
height:100px;
margin-left:20px;
background:green;
float:left;
}
.video{
width:200px;
height:100px;
margin:0 auto;
background:green;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With