#media function not responding when trying to change height of div - html

I'm trying to change the height of a certain div.
Somehow, the div gets a default height of 964px.
When I'm trying to change the height by using style: height:40vw; inside the div tag, it works just fine, but when I'm using the #media function without the style, it doesn't work.
I'm referring to the div with class and id of parent-container.
Here is my code:
HTML
<div class="content">
<div class="parent-container" id="parent-container" style="position: relative;top: 0;">
<div id="video-container"
style="z-index: -1; min-height: 100%;min-width: 100%; position: absolute; top: 0;left: 0; transition-delay: 500ms;overflow-y: hidden">
<video class="fade-in" autoplay loop muted
style="min-width:100%;max-height:100% ;position: fixed; left: 0; top: 0; object-fit: fill;">
<source id="mp4" src="images/video.mp4" type="video/mp4">
<p>Your user agent does not support the HTML5 video elemnt</p>
</video>
</div>
<div class="videoRGBA">
<img src="images/brush.png" style="position: relative; top: 15vw; left: 50px">
<div style="position: relative; top: 0.8vw;">
NOT RELEVANT
</div>
</div>
</div>
CSS
#media only screen and (min-width 427px){
.parent-container{
height: 100vw;
}
}
#media only screen and (min-width 0px) and (max-width 426px){
.parent-container{
height:90vw;
}
}
Thanks.

I missed ":" in the media query.
instead of
#media only screen and (min-width 427px){
.parent-container{
height: 100vw;
}
}
#media only screen and (min-width 0px) and (max-width 426px){
.parent-container{
height:90vw;
}
}
Just changed to:
#media only screen and (min-width :427px){
.parent-container{
height: 100vw;
}
}
#media only screen and (min-width: 0px) and (max-width: 426px){
.parent-container{
height:90vw;
}
}

Related

HTML background-color : Is it possible to fill the screen from a div?

I have an issue with the reponsive of my website. In desktop mode, I have a div in the center of my screen with a grey background-color. In tablet mode, I would like to let my div and its content centered in the screen, but fill the entire width of the screen with grey. Is it possible?
#media screen and (min-width: 767px) and (max-width: 1366px) {
.backgroundGrey {
background-color: #F2F2F2;
/* please tell me it's possible */
}
}
<body>
<section>
<div class="flexCenter backgroundGrey">
<div>
<h2>Content
<h2>
</div>
</div>
</section>
</body>
EDIT with solution
Thank you all for your answers, I mixed it up and found a solution to my problem. I added a new div with my background-color set in position absolute:
<body>
<section>
<div class="backgroundGreyFullWidth"></div>
<div class="flexCenter">
<div>
<h2>Content</h2>
</div>
</div>
</section>
</body>
#media screen and (min-width: 767px) and (max-width: 1366px) {
.backgroundGreyFullWidth {
background-color: #f2f2f2;
position: absolute;
z-index: -1;
width: 100%;
height: 650px;
left: 0;
right: 0;
}
}
Just use absolute or fixed positioning and tie element to each side, like so:
.backgroundGrey {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #F2F2F2;
/* other attributes to position content inside */
}
you must using the two div, first div for background color and second div for Keep content
Follow the codes below :
<body>
<section>
<div class="flexCenter backgroundGrey">
<div class="content">
<h2> Content <h2>
</div>
</div>
</section>
</body>
#media screen and (min-width: 767px) and (max-width: 1366px) {
.backgroundGrey {
background-color: #F2F2F2;
width : 100%;
height : 100%;
}
.content{
width:200px;
}
}
Use width and height 100%
.backgroundGrey {
background-color: #F2F2F2;
width:100%;
height:100vh;
display:flex;
justify-content:center;
align-items:center;
}
<div class="backgroundGrey">content</div>

Margin White Stripe

Im having trouble getting rid of what it appears to be a margin error?...i've already tried setting margin and padding values as 0 but i keep getting that line, should i downsize the video or something?
I inserted the background video on a div tag. Is the video just out of place?
/* Default to hide the video on all devices */
#video{display:none}
/* Default to display the image on all devices */
#videosubstitute{display:block;width:auto;height:100%;}
html, body {
height: 100%;
margin: 0;
}
/*START VIDEO
==================================================*/
#fullScreenDiv{
width:100vh;
min-height: 100vh;
/* Set the height to match that of the viewport. */
height: 100vh;
width: auto;
padding:0!important;
margin: 0!important;
background-color: black;
position: relative;
}
#video{
width: 100vw;
height: auto;
object-fit: cover;
left: 0px;
top: 0px;
z-index: 1;
volume: .02;
}
#media (min-aspect-ratio: 16/9) {
#video{
height: 150%;
top: -100%;
}
#videosubstitute{
display:block;
width: 100%;
height: auto;}
}
#media (max-aspect-ratio: 16/9) {
#video {
width: 150%;
left: -100%;
}
#videosubstitute{display:block;width:auto;height:100%;}
}
/*if there is 992 pixels or more, then display the video but hide the image*/
#media only screen and (min-width : 992px) {
#video{display:block;}
#videosubstitute{display:none}
}
/* The container for our text and stuff */
#messageBox{
position: absolute; top: 0; left: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height:100%;
}
/*END VIDEO
==================================================*/
<div id="fullScreenDiv" class="table-cell">
<img src="https://www.imi21.com/wp-content/uploads/2016/11/t12.jpg" id="videosubstitute" alt="Full screen background video"></img>
<div id="videoDiv">
<video preload="preload" id="video" autoplay="autoplay" loop="loop">
<!-- Note: Replacing the following sources that are local:
<source src="img/mc10.webm" type="video/webm"></source>
<source src="img/mc10.mp4" type="video/mp4"></source> -->
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"></source>
</video>
</div>
</div>
This line seems off:
width:100vh;
vh means percent of the screen height. Probably a bad idea to use that as width.
Are you really sure you want the video to be cut off at the sides of the screen? Wouldn't it be better to have a black background and let the video fill the available space without stretching? E.g. fill: contain

How to display youtube video in background with full screen

I added youtube video in background but still it's not in full screen.
In left side and right side I'm still getting black background.
Here is my code:
<section class="banner-video">
<div class="banner-video-inner">
<iframe height="100%" width="100%" src="https://www.youtube.com/embed/<?php the_field('banner_video_link');?>?autoplay=1" frameborder="0" allowfullscreen></iframe>
</div>
</section>
.banner-video{position: relative; z-index: 0; width:100%; height:650px;}
.banner-video-inner{ position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none; z-index: 2;}
I used the_field using advance custom field plugin.
so can anyone tell me how to show video in full screen and remove that left and right side black background ??
Apply video to video tag and add CSS from below code:
body {
margin: 0;
background: #000;
}
video {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
transform: translateX(-50%) translateY(-50%);
background-size: cover;
}
<video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" playsinline autoplay muted loop>
<source src="http://thenewcode.com/assets/videos/polina.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
</video>
.banner-video{position: relative; z-index: 0; width:100%; height:759px;}
#media only screen and (min-width:1400px){
.banner-video{height:843px;}
}
#media only screen and (min-width:1520px){
.banner-video{height:948px;}
}
#media only screen and (max-width:1199px){
.banner-video {height:576px;}
}
#media only screen and (max-width: 992px){
.banner-video {height:432px;}
}
#media only screen and (max-width: 640px){
.banner-video {height:318px;}
}
#media only screen and (max-width: 400px){
.banner-video {height: 180px;}
}
Finally This Works for me. Got the video in full screen.

How do I keep my video div/container/wrapper from moving when I zoom in and out?

Here's what's happening. I dont want my video to be full width. I want it a specific width. When I change the width the container sends the video to the left side. Then when I put in the middle it appears to be fine....until you zoom in and out and the div/container/wrapper moves the video.
How can I solve this?
How do I keep my video div/container/wrapper from moving when I zoom in and out?
The video is directly under the navigation bar so I'm sure it has something to do with the header's div/wrapper width. Please help.
HTML
-->
<div class="video-background" id="video-background">
<video loop="loop" autoplay poster="{{ 'home-placeholder.jpg' | asset_url }}" width="100%">
<source src="{{ 'home.mp4' | asset_url }}" type="video/mp4">
<source src="{{ 'home.webm' | asset_url }}" type="video/webm">
<source src="{{ 'home.ogg' | asset_url }}" type="video/ogg">
<img alt="" src="{{ 'home-placeholder.jpg' | asset_url }}" width="640" height="360" title="No video playback capabilities, please download the video below">
</video>
Scroll Down
</div>
And CSS
div.video-background {
height: 100%;
left: 0;
overflow: hidden;
/*position: fixed;
top: 96px;*/
vertical-align: top;
width: 100%;
/*z-index: -1; */
margin-top:96px;
position:relative;
}
div.video-background video {
min-height: 100%;
min-width: 100%;
z-index: -2 !important;
}
div.video-background > div {
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: 10;
}
div.video-background .circle-overlay {
left: 50%;
margin-left: -590px;
position: absolute;
top: 120px;
}
div.video-background .ui-video-background {
display: none !important;
}
.index .sub-footer {
margin-top:0px;
}
I finally found an answer to this or a fix.
I tried three different things.
Setting different px values at different screen intervals
#media screen and (max-width: 1180px){
div.video-background video {
width:1000px;
}
}
#media screen and (max-width: 801px){
div.video-background video {
width:700px;
}
}
Also tried
width:auto;
Didn't do the trick.
I then tried em
#media screen and (max-width: 75em){
div.video-background video {
width:50em;
}
}
#media screen and (max-width: 65em){
div.video-background video {
width:30em;
}
}
Worked better but didn't solve it.
I finally tried vh setting width and height as vh
#media screen and (max-width: 1180px){
div.video-background video {
width:60vh;
height:60vh;
}
}
#media screen and (max-width: 801px){
div.video-background video {
width:40vh;
height:40vh;
}
}
And that fixed the issue. Please take these values with a grain of salt as they do not really represent the actual numbers I used. But hopefully this helps you in the future when dealing with browser zoom, overlapping elements, and moving divs.

hide HTML5 video using media query

I've got a landing page with a fullscreen width & height video background. Everything works fine. However, when I try to hide the video on mobile resolution using media queries, it doesn't hide at all.
I've tried enclosing the video in a div, and setting that div to display none. Didn't work either.
Does anyone have any idea how I could hide a background video for mobile devices?
Here's the main code.
HTML:
<div id="video_bg">
    <video id="video_background" autoplay loop>   
        <source src="backgroundmovie.webm" type="video/webm" />
<source src="backgroundmovie.mp4" type="video/mp4" />  
    </video>
</div>
CSS:
#video_background {
position: absolute;
bottom: 0px;
right: 0px;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1000;
overflow: hidden;
}
#media only screen and (max-width: 960px) {
#video_bg { display:none; }
#video_background { display:none; }
}
You can try #media only screen and (max-width: 960px) {#video_bg:display:none !important;} just to check weather it works or not.
EDIT
Or you can inherit the above tags and then do a display:none; like below.
#media only screen and (max-width: 960px) {
div#video_bg video#video_background source {display:none;}
}
Hope this helps.