What is the best way to align these Iframes in the center?

This is the html

<div class="main_content">
    <section class="episodio">
      <article class="contenedor_episodios">
        <h2>Episodios</h2>
        <div class="episodio_spotify">
          <iframe
            src="https://open.spotify.com/embed-podcast/show/2ySVrxGkN6n6frMTo9Nsrt"
            width="100%"
            height="225"
            frameborder="0"
            allowtransparency="true"
            allow="encrypted-media"
          ></iframe>
        </div>

        <div class="episodio_spotify">
          <iframe
            src="https://open.spotify.com/embed-podcast/show/4kYCRYJ3yK5DQbP5tbfZby"
            width="100%"
            height="225"
            frameborder="0"
            allowtransparency="true"
            allow="encrypted-media"
          ></iframe>
        </div>

        <div class="episodio_spotify">
          <iframe
            src="https://open.spotify.com/embed-podcast/show/5JxcIaIkN8zx3Zy7yD9snv"
            width="100%"
            height="225"
            frameborder="0"
            allowtransparency="true"
            allow="encrypted-media"
          ></iframe>
        </div>

        <div class="episodio_spotify">
          <iframe
            src="https://open.spotify.com/embed-podcast/show/2Iibd5A6R7mxkCm4NwNmUn"
            width="100%"
            height="225"
            frameborder="0"
            allowtransparency="true"
            allow="encrypted-media"
          ></iframe>
        </div>
      </article>
    </section>
  </div>   
    

And this is the CSS for this piece of code.

    .main_content {
.episodio {
  grid-area: auto;
  padding-bottom: 100px;
  background: linear-gradient(#0000ff, #0000a3);
  .rectangle_background {
    .contenedor_episodio {
      display: grid;
      // justify-items: center;
      grid-template-columns: auto auto;
      .episodio_spotify {
        width: 500px;
        height: 300px;
        margin: 0 auto;
        display: flex; /* new */
        align-items: center; /* new */
        justify-content: center;
        //grid-template-columns: repeat(auto-fit, minmax(400px, 2fr));
        iframe {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}

}

Im tried different solutions to center this Iframes based on this question

https://stackoverflow.com/questions/45536537/centering-in-css-grid/45599428#:~:text=Use%20margin%3A%20auto%20to%20vertically%20and%20horizontally%20center%20grid%20items.&text=To%20center%20the%20content%20of%20grid%20items%20you%20need%20to,margins%20to%20the%20new%20elements.

but I can't seem to get the title "Episodios" or the spotify Iframes to center properly.

Is there something I'm missing? Any advice would be appreciated.

Regards

EDIT:

Using a css query, the mobile view seems to work fine. I believe the issue lies in it still utilizing the css code from the mobile view of 360px.

@media screen and (min-width: 1024px) and (max-width: 1440px) {

Answer №1

give this a shot

.spotify_episode {
  width: 500px;
  height: 300px;
  margin: 0 auto;
}

.spotify_episode iframe {
  width: 100%;
  height: 100%;
}

hopefully I grasped your question correctly

Answer №2

After some troubleshooting, I discovered that the issue stemmed from a missing div called .rectangle_background. In previous iterations, I had deleted this div, causing the CSS to malfunction entirely. – Andresfjobs just now Edit

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

Adjust the width of the dropdown menu for the v-combobox

I am currently working on creating a multiple search filter similar to the one found in Gitlab dashboard. For this task, I am utilizing Vuetify's v-combobox like this : <v-combobox id="mycombo" v-model="model&qu ...

Issue with JavaScript not executing upon clicking the submit button on a form within the Wordpress admin page

In the admin pages of my Wordpress installation, I have created an HTML form. My goal is to validate the data inputted when the submit button is pressed using a Javascript function. If the data is not correctly inserted, I want alerts to be displayed. Desp ...

Using DIV to "enclose" all the elements inside

I need assistance with my HTML code. Here is what I have: <div id="cover" on-tap="_overlayTapped" class$="{{status}}"> <form method="POST" action="/some/action"> <input required id="name" name="name" label="Your name"></input> ...

Tips for aligning the Bootstrap inline form in the center of the webpage

Is there a way to center align my form in such a way that the input box and button appear in the same row? I've tried the code below, but for some reason they don't display inline. Can anyone provide a code sample to help me achieve this? Your as ...

Can PurgeCSS be implemented with Next.js and module.scss files?

Is there a way to use purgeCSS with component level .scss files (filename.module.scss) in order to remove unused CSS? The hashed classnames make it tricky, especially in a next.js app that heavily relies on module.scss files for styling. This thread here ...

Utilize Vue.js to easily upload images alongside form input fields

I have recently started a small project with Vue Js. I am trying to incorporate an upload file option in my contact form. Due to the numerous input text fields, I am using serialize for the form. However, I am facing issues with the append function. How ca ...

What is the best way to delete stored angularjs files permanently?

My web application, built on AngularJS, has certain functionalities that I have hidden from users. While the controls have been successfully hidden in the updated version of the file, there are still some users with the old file who can access these undesi ...

Omitting an element from the CSS styling

How can I create a CSS selector that targets the text content within this snippet, excluding the <label> component? Essentially, I want to style the text in the div while leaving the label unchanged. <div id="edit-cc" class="form-item form-type ...

The positioning problem arising from using a Vuetify select dropdown within a datatable

Vuetify datatable is being used with 20 columns, functioning properly. To view all the columns, horizontal scrolling is available. Filters are needed for each column in the header, achieved using v-slot:header. An issue arises when clicking on the select ...

How to center align an HTML page on an iPhone device

I am currently testing a HTML5 webpage on my iPhone, utilizing CSS3 as well. The page appears centered in all browsers except for the iPhone, where it is left aligned. I have attempted to use the following viewport meta tag: <meta name="viewport" conte ...

Personalized HTML selection list

When a select option is too long, it stretches the container to accommodate its length. I have created a truncate function to limit the display to 20 characters and add ellipses to prevent this stretching. I have been searching for a way to show the entir ...

I need to show a DIV element when a specific anchor is in an active state within an HTML document

Is there a way to make the code below only visible when the url ends with #404? <!--404 code--> <style> .div1 { width: 300px; height: 100px; border: 1px solid blue; border-color: #ff0263; box-sizing: border-box; } < ...

Ensure that the mask implemented in the form input only shows two decimal places, while simultaneously retaining the original value

Is there a way to format a number in a form input so that it displays only two decimals while still retaining the original value? This is necessary to avoid incorrect values down the line and meets the customer's requirement of showing no more than tw ...

Printing from a lengthy React DOM using window.print only generates a single page

My React component is capable of rendering markdown and can span multiple pages. Everything looks great when the component is displayed in the browser - scrolling works perfectly. However, whenever I try to print the page using window.print or ctrl + P, ...

Modify the variable to encompass a multitude of hues - scss

Hello, I am looking to modify the background of a page for dark mode. This is the current background styling: $orangeLight:#FFA500!default; $redLight:#FA8072!default; $blueLight:#B0C4DE!default; $greenLight:#90EE90!default; $list2: $blueLight 0%,$blueLi ...

Tips on preserving CSS modifications made in Chrome Developer Tools Inspector to .vue file

Currently, I am in the process of setting up a new workflow where my goal is to streamline my work by using the Chrome DevTools Inspector to save any CSS changes directly to my .vue file. While the DevTools Workspaces feature can achieve this, it involves ...

Avoiding redirection in Django template form

Currently, I am facing a challenge with my application that involves rendering a Django Template model form where images are referenced from another model. To manage the addition and deletion of images for this other model, I have implemented a button wit ...

Type content in HTML5

Can you help me with a simple question? I am currently working on building my portfolio using html https://i.stack.imgur.com/rxYRS.png I want to be able to click on an image and add the description of my choice. Right now, it is showing something else: ...

Possible conflict between CSS and JavaScript on Magento website

Problem Description: Visit this link for more details I am facing an issue with the product upload process when using certain attributes. It appears to be related to a positioning problem. Despite trying various solutions, such as removing the position at ...

Take away the attention from the span element

I have been experimenting with the following jsfiddle and attempted various methods suggested in this Stack Overflow thread, but I am struggling to remove the focus from the "feedback" span after clicking on the cancel button in jQuery confirm dialog. Her ...