Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the gap between HTML5 video tag

How to reduce the gap between two video tag, I have tried with margin and padding its not worked any help are appreciated

DEMO

My HTML

<div class="videoTest">
    <video controls="controls"></video>
    <video controls="controls"></video>
    <video controls="controls"></video>
    <video controls="controls"></video>
</div>

My CSS

.videoTest > video{
    border:1px solid red;
    margin:0;
    padding:0;    
}
like image 518
Thirumalai murugan Avatar asked Jun 24 '13 10:06

Thirumalai murugan


People also ask

How do I reduce space between sections in HTML?

Just write * { margin: 0; padding: 0; } at top of css code. Else, if you are having other whitespace issues with inline elements, you can fix them using font-size: 0; on the container of the affected elements.

Why is there a gap between my divs?

This is caused by the fact your browser will render the DIV's inline and as with words, they are separated by spaces. The width of the space is determined by the font-size, hence an easy trick is to set the font-size of your containing element to 0 and then reset the font-size in your inline divs.


2 Answers

The <video> element is an inline element by default. That's why there are gaps between them representing the whitespaces and/or line-breaks in your markup.

.videoTest > video {
    display: inline-block;
    border:1px solid red;
    margin:0;
    padding:0;    
}

.videoTest {
    font-size: 0;
}

By using font-size: 0, the line-breaks and whitespaces are being kind of ignored and you get rid of the gaps. Their size is set to 0.

Updated Fiddle

This is a common workaround when working with inline-blocks and is in some situations superior to floats when it comes to centering for example.

like image 183
Kilian Stinson Avatar answered Oct 05 '22 06:10

Kilian Stinson


try this

http://jsfiddle.net/Ng6XU/5/

.videoTest > video{
    border:1px solid red;
    margin:0px;
    padding:0; 
    float:left;
}
like image 32
sangram parmar Avatar answered Oct 05 '22 05:10

sangram parmar