-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)
Responsive videos automatically scale to fit different screen sizes and maintain their aspect ratio (usually 16:9) without being cut off or distorted.
By default, <video>
or <iframe>
elements (like YouTube) use fixed width/height, which may overflow or not adjust properly on smaller screens.
✅ Keeps layout clean across devices
✅ Avoids horizontal scroll on mobile
✅ Maintains correct aspect ratio
✅ Improves user experience on all screen sizes
✅ Works well with embedded videos (e.g. YouTube, Vimeo)
aspect-ratio
)<div class="video-wrapper">
<iframe src="https://www.youtube.com/embed/ScMzIvxBSi4" allowfullscreen></iframe>
</div>
.video-wrapper {
aspect-ratio: 16 / 9;
width: 100%;
}
.video-wrapper iframe {
width: 100%;
height: 100%;
border: none;
}
✅ Benefit: Clean, minimal code with native CSS support (modern browsers).
padding-bottom
Hack (Traditional Method)<div class="video-container">
<iframe src="https://www.youtube.com/embed/ScMzIvxBSi4" allowfullscreen></iframe>
</div>
.video-container {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
height: 0;
overflow: hidden;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
✅ Benefit: Works in all modern browsers including older ones.
<video>
Tag Responsive<video controls class="responsive-video">
<source src="movie.mp4" type="video/mp4">
</video>
.responsive-video {
width: 100%;
height: auto;
max-width: 800px;
display: block;
margin: auto;
}
✅ Write HTML/CSS for the following:
Q1. Create a responsive YouTube embed using the aspect-ratio
property.
Q2. Use the padding-bottom
trick to make an iframe responsive.
Q3. Make an HTML5 <video>
scale with the screen width.
Q4. Embed a Vimeo video that maintains 16:9 ratio.
Q5. Make a video player center-aligned and responsive.
Q6. Apply media queries to adjust video margins on mobile.
Q7. Use max-width
to restrict video size on large screens.
Q8. Add responsive subtitles using <track>
in HTML5 video.
Q9. Create a responsive layout with 2 videos side-by-side on desktop and stacked on mobile.
Q10. Add responsive background video with object-fit: cover
.
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)