What could be causing the content to disappear when switching from flex: column to flex: row?

In the code snippet provided below, you may notice that when the screen size is less than 768px, the video and content underneath it are visible. However, as soon as the screen size exceeds 768px, the video disappears.

Have you ever wondered why the video vanishes when transitioning from flex-direction: column; to flex-direction: row;?

Click here for the Codepen link if you prefer...

/* Duru Sans */
@import url("https://fonts.googleapis.com/css2?family=Duru+Sans&display=swap");
/*resets*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: "Duru Sans", sans-serif;
  font-size: 16px;
  color: #000a70;
}

a {
  text-decoration: none;
}

.container {
  padding-right: 24px;
  padding-left: 24px;
  width: 100%;
}

.people-love-cats h2 {
  font-size: 2.25rem;
  line-height: 2.75rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 2rem;
}

.video-slider {
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .video-slider {
    flex-direction: row;
  }
}
.video-slider__video {
  /* embed video */
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
}
.video-slider__video iframe,
.video-slider__video object,
.video-slider__video embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.video-slider__content {
  padding: 2rem;
  background: #f2f5f9;
}
.video-slider__content h6.kicker.kicker--light {
  font-size: 0.75rem;
  line-height: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.video-slider__content h4 {
  margin-top: 1rem;
  font-size: 1.75rem;
  line-height: 2.25rem;
  font-weight: 900;
}
.video-slider__content p {
  margin-top: 1.25rem;
  font-size: 1rem;
  line-height: 1.5rem;
}
.video-slider__content .txt-link {
  margin-top: 2rem;
}

.txt-link {
  display: inline-flex;
  align-items: center;
}
.txt-link a {
  color: #005fec;
  font-weight: 700;
  font-size: 1.125rem;
  position: relative;
}
.txt-link a:hover::after {
  visibility: visible;
  width: 100%;
}
.txt-link a::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: #005fec;
  visibility: hidden;
  transition: all 0.2s ease;
}
.txt-link img {
  height: 0.75rem;
  margin-left: 0.5rem;
}
<div class="container">
  <div class="people-love-cats">
    <h2>People love Cats.</h2>
    <div class="video-slider">
      <div class="video-slider__video">
        <iframe src='https://www.youtube.com/embed/2acZIOSV9LY' frameborder='0' allowfullscreen></iframe>
      </div>
      <div class="video-slider__content">
        <h6 class="kicker kicker--light">
          Customer Story
        </h6>
        <h4>Company Name</h4>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae, maiores.</p>
        <span class="txt-link arrow-link">
          <a href="#">Read more</a>
          <img alt="arrow right icon" class="learn-more-arrow" src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg" loading="lazy">
        </span>
      </div>
    </div>
  </div>
</div>

Answer №1

Greetings,

Adding max-width:100% without specifying the width can lead to unexpected results.

In your case, using width: 100% is more appropriate.

To resolve this issue, simply include a specified width in the media query.

@media (min-width: 768px) {
  .video-slider {
    flex-direction: row;
  }
  .video-slider__content {
    width: 50%;
  }
  .video-slider__video {
    width: 50%;
  }
}

After making these edits, you should see the desired functionality working as intended.

 /* Duru Sans */
@import url("https://fonts.googleapis.com/css2?family=Duru+Sans&display=swap");
/*resets*/
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: "Duru Sans", sans-serif;
  font-size: 16px;
  color: #000a70;
}

a {
  text-decoration: none;
}

.container {
  padding-right: 24px;
  padding-left: 24px;
  width: 100%;
}

.people-love-cats h2 {
  font-size: 2.25rem;
  line-height: 2.75rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 2rem;
}

.video-slider {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .video-slider {
    flex-direction: row;
  }
  .video-slider__content {
    width: 50%;
  }
  .video-slider__video {
    width: 50%;
  }
}
.video-slider__video {
  /* embed video */
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
}
.video-slider__video iframe,
.video-slider__video object,
.video-slider__video embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.video-slider__content {
  padding: 2rem;
  background: #f2f5f9;
}
.video-slider__content h6.kicker.kicker--light {
  font-size: 0.75rem;
  line-height: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.video-slider__content h4 {
  margin-top: 1rem;
  font-size: 1.75rem;
  line-height: 2.25rem;
  font-weight: 900;
}
.video-slider__content p {
  margin-top: 1.25rem;
  font-size: 1rem;
  line-height: 1.5rem;
}
.video-slider__content .txt-link {
  margin-top: 2rem;
}

.txt-link {
  display: inline-flex;
  align-items: center;
}
.txt-link a {
  color: #005fec;
  font-weight: 700;
  font-size: 1.125rem;
  position: relative;
}
.txt-link a:hover::after {
  visibility: visible;
  width: 100%;
}
.txt-link a::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: #005fec;
  visibility: hidden;
  transition: all 0.2s ease;
}
.txt-link img {
  height: 0.75rem;
  margin-left: 0.5rem;
}
    <div class="container">
      <div class="people-love-cats">
        <h2>People love Cats.</h2>
        <div class="video-slider">
          <div class="video-slider__video">
            <iframe
              src="https://www.youtube.com/embed/2acZIOSV9LY"
              frameborder="0"
              allowfullscreen
            ></iframe>
          </div>
          <div class="video-slider__content">
            <h6 class="kicker kicker--light">Customer Story</h6>
            <h4>Company Name</h4>
            <p>
              Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae,
              maiores.
            </p>
            <span class="txt-link arrow-link">
              <a href="#">Read more</a>
              <img
                alt="arrow right icon"
                class="learn-more-arrow"
                src="https://nextivaweb.imgix.net/icons/Arrow-Right-Hover-Animation.svg"
                loading="lazy"
              />
            </span>
          </div>
        </div>
      </div>
    </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Incorporating the 'react-day-picker' DatePickerInput in a Bootstrap Modal Interface

I am attempting to incorporate a DatePickerInput component into a bootstrap modal. I am hoping to achieve a similar look as shown on the official website here. However, when placed inside the bootstrap modal, it appears like this. My assumption is that ...

Tips for adjusting the color of a row when hovering

Can I modify the row color on hover in material-table using props? Similar to this example. Appreciate your help. ...

Navigating through tabs in a Meteor application: How to maintain the active tab when using the back button

I am working on a multi-page meteor application where each page includes a navigation template. To switch between pages, I am using iron-router. The user's current page is indicated by setting the appropriate navigation link's class to 'ac ...

Tips for ensuring that the elements within the flexbox are centered and aligned to the left

New proposed layout I need assistance with centering all flexbox items in a 3-column layout. Additionally, I want the items in rows that are not full to be centered and aligned to the left. Any suggestions for achieving this? Below is my current code, bu ...

CodeMirror - Issue with setting AutoComplete "options" correctly

I've been using CodeMirror and trying to style the autocomplete pop up with CSS. It's been a challenge because the pop up disappears when I inspect styles and make changes. I came across some code in show-hint.js that looks like this: if (optio ...

Ways to conceal CSS on the page when triggering a different element

I am trying to achieve the functionality of hiding the black arrow when clicking on the green arrow, all without using jQuery. Here is my fiddle: http://jsfiddle.net/t5Nf8/195/ html: <div class="arrow-down"></div> <div class="arrow-up"> ...

`The dilemma of z-index in a dropdown menu nested within an animated card`

Having an issue that I have attempted to simplify in this StackBlitz example (the actual project is created with Angular components and Bootstrap, etc.): https://stackblitz.com/edit/angular-bootstrap-4-starter-njixcw When incorporating a dropdown within ...

Steps to create an iframe that opens in a new window

I'm facing an issue with the iframe sourced from flickr. My website includes an embedded flickr iframe to showcase a gallery without the hassle of creating a slider, resizing images, and extracting thumbnails. Given that this site belongs to a frien ...

Is it possible to access the HTML template prior to Outlook applying any additional classes during rendering?

I recently received an email template created in a different platform via Outlook. I am attempting to recreate this email in the Salesforce Marketing Cloud Platform, but I am encountering numerous unnecessary tables, classes set by Outlook (MsoNormal, Ms ...

CSS does not appear to be showing on the banner

I am struggling to get my banner to display correctly using the CSS code below. #banner { background-image: url(../Images/banner.png); background-repeat: no-repeat; background-size: cover; border: 5px solid #dedede; height: 200px; } ...

Using Twitter Bootstrap to set a minimum number of lines for thumbnail captions

I currently have a carousel on my website created using Bootstrap that displays 4 columns of thumbnails. You can view the carousel here. When navigating to the third page of the carousel, you will notice that the container increases in height to accommodat ...

Implementing a dual-column design for MailChimp using HTML and CSS

I'm feeling overwhelmed. I have a MailChimp layout that I exported from MailChimp. Currently, the layout consists of 3 columns, but on mobile, it converts to 1 column. Here is the link to the codepen: goo.gl/Fj8Ct7 Is there anyone who can assist me ...

Customize Your Contact Form in Wordpress with a Stylish 2-Column Layout

Hey there, I've encountered a little problem with my website. My website is built on Wordpress and uses Contact Form 7, which has been heavily customized with CSS. While it looks great on desktop, the email field appears too small on mobile devices. I ...

Steps for activating flex to true in Bootstrap 4 using SCSS

I have successfully installed the latest version of Bootstrap using bower. I am utilizing gulp tasks to convert it into CSS. Within my style.scss file, I have included: @import "bootstrap"; @import "font-awesome"; Everything is functioning properly at th ...

What's the best way to ensure that Bootstrap columns have consistent height with space in between?

Looking to create three columns of equal height in Bootstrap, with no gaps between them? Check out this screenshot for reference: Screenshot Below is the code snippet you can use: <div class="container"> <div class="row mt-4&qu ...

Having trouble achieving the desired effect with inline block

I'm having some trouble creating a simple store page. One of the products is supposed to look like this: https://i.sstatic.net/JLlua.png However, it's currently showing up like this: https://i.sstatic.net/hHYUm.png I've been attempting t ...

Guide on transferring the td id value to a different page

document.getElementById('scdiv').innerHTML=Quantity <td id="scdiv"> </td> document.getElementById('quantitydiv').innerHTML=mrp <td id="quantitydiv"> </td> I am currently facing an issue where the code is being d ...

implementing a collapsible sidebar menu with CSS tables

I am working on a layout with three columns created using css tables to perfectly fit the browser window. The first column serves as a menu and I want it to hide or move to the left when clicked, allowing the middle column to expand into its space. However ...

Conceal the scrollbar track while displaying the scrollbar thumb

Hey there! I'm looking to customize my scroll bar to have a hidden track like this. Everyone's got their own style, right? ::-webkit-scrollbar{ width: 15px; height: 40px; } ::-webkit-scrollbar-thumb{ background-color: #DBDBDB; borde ...

Ways to modify CSS using JavaScript

Can anyone assist me with a custom CSS code that I found? It looks like this: header.type-2:not(.fixed-header) nav>ul>li>a{ color:#000; } I've been trying to change the color to #fff using JavaScript, but haven't had any success yet. ...