Html5 Video Stretch? [SOLVED] - DaniWeb
Có thể bạn quan tâm
- Home
- Programming Forum
- Web Development Forum
- Discussion / Question
Hi all,
I have a HTML video within a div that is 100% width of the page. I want the video fill the container and crop the height to fit. But so far I cannot get the video to expand at all!
I'm simply using:
.video { width:100%; }and
<div class="main-content"> <video class="video" autoplay loop"> <source src="/wp-content/themes/StrongLinks/video.webm" type='video/webm'/> <source src="/wp-content/themes/StrongLinks/video.mp4" type='video/mp4'/> </video> </div>Can someone explain why the video object isn't obeying the 100% width command?
html-css video 0 0 Share- 2 Contributors
- 5 Replies
- 3K Views
- 4 Hours Discussion Span
- Latest Post 9 Years Ago Latest Post by James_43
I think it's been hurting heads for many years now. https://www.google.com/#q=html5+video+stretch finds you may have to find other video players or just bite the bullet and make the video exactly what you want in the first place.
0 0 ShareSo does that mean if I want a video to fill a div, that obviously changes in aspect ratio depending on the screen its viewed on... then I can't do that??
0 0 Share Last Seen 3 Hours AgoJames, I supplied the search so you could see the priors. Check the latest HTML5 video standards. I read this:
Video content should be rendered inside the element's playback area such that the video content is shown centered in the playback area at the largest possible size that fits completely within it, with the video content's aspect ratio being preserved. Thus, if the aspect ratio of the playback area does not match the aspect ratio of the video, the video will be shown letterboxed or pillarboxed. Areas of the element's playback area that do not contain the video represent nothing. 0 0 ShareQuote from the HTML5 spec for <video> tags:
I understand that a stretched video will cause letterboxing or pillarboxing. But them problem I am having is setting the width/height of the video element. For example, the CSS:
.video { width: 100px; height: 200px; }does not cause letterboxing, instead the element only obeys the width constraint. My question is why doesn't the video element also obey the height constraint and display with letterboxing?
0 0 ShareSolved. Adding position: fixed; to my CSS allows the video element to follow the constraints.
0 0 Share Share Facebook Twitter LinkedIn Reply to this topic Be a part of the DaniWeb communityWe're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.
Sign Up — It's Free! Related Topics- HTML & CSS - li items/ div's are going where they should. 2
- html5 video embedding - need help 10
- Can't save file in php 2
- HTML and CSS 1
- SQL Array 2
- Css Horizontal Dropdown Menu Visibility Problem 1
- Dynamically modifying the CSS attributes through Javascript 2
- video.js youtube Uncaught reference error: videojs is not defined 4
- how to generate rows in table dynamically 3
- html5 video - safari wants to download it all 2
- Alter object properties in the array 3
- Background video controls don't work 3
- Time Zone on PHP 4
- Css height issue 3
- dissappearing variables 1
- Fill remaining width among inline-block divs with self 3
- Checkbox showing array instead of chosen options 3
- Xuggler Audio Recorder not working, and video longer than it should be 6
- Css Expand/hide Div 4
- Problem in some HTML CSS Properties 2
Reach out to all the awesome people in our web development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.
Start New Topic Topics Feed Reply to this Topic Edit Preview Message H1 H2 Post ReplyShare Post
Permanent Link Facebook Facebook Twitter Twitter LinkedIn LinkedInInsert Code Block
Insert Code Block Search Search- Forum Categories
- Latest Content
- Newest Topics
- Latest Topics
- Latest Posts
- Latest Comments
- Top Tags
- Topics Feed
- Social
- Forums
- Top Members
- Meet People
- Community Functions
- DaniWeb Premium
- Newsletter Archive
- Markdown Syntax
- Community Rules
- Developer APIs
- Connect API
- Forum API Docs
- Tools
- SEO Backlink Checker
- Legal
- Terms of Service
- Privacy Policy
- FAQ
- About Us
- Advertise
- Contact Us
Từ khóa » Html5 Video Stretch Ratio
-
HTML 5 Video Stretch - Stack Overflow
-
HTML5-video-stretch-fullscreen.css - Gists · GitHub
-
Fluid Width Video | CSS-Tricks
-
HTML 5 Video Stretch - Newbedev
-
Emulating Background-size: Cover For HTML5 Video (CSS Only)
-
The Complete Guide To Understanding Video Aspect Ratios - Dacast
-
Aspect-ratio - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
-
CSS Object-fit Property - W3Schools
-
How To Make Html5 Video Responsive? - Digi Effects
-
Fix Aspect Ratio Of Online Videos - Alexander Pruss's Blog
-
How To Preserve The Player Aspect Ratio On A Responsive Page
-
Css – Make HTML5 Video Poster Be Same Size As Video Itself
-
Video Fit To Screen Html