Chrome and Firefox do not support floating CSS Grid columns, whereas IE and Edge do

I've been experimenting with creating my own grid system using CSS, inspired by the simplicity of Bootstrap. You can check out the CodePen page where I've shared my progress. This is the CSS I've implemented:

    /*
* light blue = 00AEEF
* dark blue = 1C75BC
* green = 8DC63F
* dark green = 009444
* orange = F7941E
* dark orange = F15A29
* brown = 594A42
*/

/***************************
****************************
Reset Styles
****************************
***************************/

@import 'normalize.css'

/* Change all elements to use border-box */

html{
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

*, *:before, *:after{
    box-sizing: inherit;
}

/***************************
****************************
Base Styles
****************************
***************************/

body{
    color: #414042 /* Dark Grey */
    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal;
}

h1, h2, h3{
    font-weight: bold;
}

a{
    color: #8dc63f; /* Green */
    font-weight: bold;
}

a:hover{
    text-decoration: underline;
}

/***************************
****************************
Layout Styles
****************************
***************************/

.container{
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
    max-width: 1170px;
}

.row{
    margin-right: -15px;
    margin-left: -15px;
}

/* ":after" is a pseudo-element (NOT a pseudo-class) */

.row::after{
    content: "";
    display: table;
    clear: both;
}

/* This targets all classes that contain the word "col-" */

[class*='col-']{
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* Media query excludes extra-small devices and includes small and above */

@media (min-width: 48em) {
    [class*='col-']{
        float: left;

    }

    /* Column One Third */

    .col-1-3{
        width: 33.3333%;
        background: red;
    }

    /* Column Two Thirds */

    .col-2-3{
        width: 66.6666%;
        background: blue;
    }
}




/***************************
****************************
Module Styles
****************************
***************************/


/***************************
****************************
Theme Styles
****************************
***************************/

.background-primary{
    background: #F7941E; /* Orange */
}

.background-secondary{
    background: #00AEEf; /* Blue */
}

.background-tertiary{
    background: #8DC63F; /* Green */
}

This is the HTML code I'm using:

 <header class="background-primary">
    <div class="container">
        Header Content
    </div>
  </header>

  <main>
    <section class="background-secondary">
        <div class="container">
            Hero Primary Content
        </div>
    </section>

    <section>
        <div class="container">
            <div class="row">
                <div class="col-1-3">
                    Circle Image
                </div>
                <div class="col-2-3">
                    Content Area
                </div>
            </div>
        </div>
    </section>



    <section>
        <div class="container">
            Featured Content
        </div>
    </section>

    <section class="background-primary">
        <div class="container">
            Testimonial Content
        </div>
    </section>

    <section class="background-secondary">
        <div class="container">
            Media Objects
        </div>
    </section>

    <section class="background-tertiary">
        <div class="container">
            More Content
        </div>
    </section>
  </main>

  <footer class="background-primary">
    <div class="container">
        Footer Content
    </div>
  </footer>

In IE and Edge browsers, both "Circle Image" and "Content Area" align horizontally as expected. However, when viewed in Chrome or Firefox, they stack vertically for some users. While it may be due to padding, what could be causing this discrepancy among browsers? Is there a common glitch reported for this issue?

(As a newcomer to web development, I apologize if this is a basic inquiry)

Answer №1

Considering your preference for a design "similar to bootstrap," it seems that you are not utilizing or open to using Bootstrap. Let's delve into grids.

When working with a grid layout, it is essential to specify certain dimensions for optimal functionality. Additionally, wrapping the entire grid within a <div> container is recommended.

By doing so, and instructing elements to adhere to the parent container's width limit with {max-width:100%}, a responsive grid layout can be achieved smoothly:

(view the snippet in fullscreen mode and resize your window to observe how the elements rearrange based on screen size)

/* Grid CSS Begins */

      .myitem {
        display: inline-block;
        width: 300px;
        max-height: 260px;
        border-bottom: 1px solid #555;
      }
      .mycoolcontainer,
      .myitem {
        margin: .4em;
      }
      img,
      .mycoolcontainer,
      .myitem {
        max-width: 100%;
      }
      /* End of CSS */

      /* Visual Effects Begin */

      body {
        background: #131418;
        color: #999;
        text-align: center;
      }
      .dark {
        box-shadow: inset 0 0 50px 30px rgba(0, 0, 0, 0.5);
      }
      #bg1 {
        background: gray
      }
      #bg2 {
        background: teal
      }
      #bg3 {
        background: darkgreen
      }
      #bg4 {
        background: LightSkyBlue
      }
      #bg5 {
        background: brown
      }
      #bg6 {
        background: DarkSeaGreen
      }
      #bg7 {
        background: BurlyWood
      }
      #bg8 {
        background: Salmon
      }
      /* End of Visual Effects */
<div class="mycoolcontainer">

     <div class="myitem dark" id="bg1">
       <img src="https://unsplash.it/400/295/?random">Title
     </div>

     <div class="myitem dark" id="bg2">
       <img src="https://unsplash.it/400/296/?random">Title
     </div>
     
     <!-- Remaining grid items omitted for brevity -->

   </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

Ways to achieve a consistent font style in a Photoshop design

After recently starting to dabble in Photoshop, I managed to create a cool text effect a few days ago. Now, I'm looking to achieve the same effect and apply it to a different image. The text contains a date that I want to update, but I can't reme ...

Tips for Controlling an Absent Search Bar in the HTML Source Code with Selenium

I'm attempting to automate searches using Selenium in Java. Upon inspecting the search bar on the page, I noticed that it has an id of searchBox and a name of q, which could be helpful. However, these properties are not visible in the HTML when viewi ...

Simple way to extract the values from every input element within a specific <tr> tag using JQuery

Is there a way to align all input elements in a single row within my form? For example, consider the snippet of code provided below, which includes a checkbox and a text input box. I would like to retrieve the values from both of these input types and pres ...

Tips for implementing event handlers on dynamically generated li elements in VueJS

Creating multiple ul elements using v-for in the following way <div v-for="item in info"> <ul> <li><a>{{item.number}}</a></li> <li><a>{{item.alphabet}}</a></li> </ul> </div&g ...

Javascript error: The variable calculator_test has not been defined

Why am I receiving an error message: Uncaught ReferenceError: calculator_test is not defined index.html: <!DOCTYPE html> <html> <body> <p>Click the button</p> <button onclick="calculator_test()">test</button> &l ...

Guide on integrating animate.css animations with Vue's Transition and TransitionGroup components

Vue offers the v-if and v-for directives that allow you to manipulate elements in the DOM based on certain conditions. In order to animate elements controlled by v-if and v-for, you need to utilize the built-in Transition and TransitionGroup components. Bu ...

retrieving or submitting information using jquery and displaying the URL in the browser's address bar

So, I have a deadline looming tomorrow morning.. I'm currently working with jQuery, trying to load data from an external file. What I really need help with is figuring out how to load new data when I use $.post or $.get in jQuery. Sending a request ...

Implementing a list using display: inline-block without any specified order

Currently, I am immersed in a project that involves simulating an input using HTML and CSS. This input should be capable of executing a function like: my_cool_function(param0, param1, param2, param3). To accomplish this, I have constructed an unordered lis ...

Hover and hover-off functions in navigation menu

html <div class="hidden-nav"> <h4>lorem</h4> <ul class="decor-menu-list"> <li><a href="#">123</a></li> <li><a href="#">123</a></li> <li><a hre ...

Incorporate JavaScript code into an Angular UI-Router view

I can't seem to find an answer to this question anywhere, so I'm hoping someone here can help me out. In my AngularJS app, I am using ui-router to load multiple views into the same <ui-view> element. I am trying to implement Jquery UI&apos ...

Adhesive side panel using Bootstrap 5

I've run into an issue while trying to make a side div sticky using Bootstrap 5. I applied the position-sticky class, but it doesn't seem to work as expected. Surprisingly, it works for the top div that I also want to stick. Adding fixed-top or s ...

How can we ensure that the entire BS4 Navbar (on smaller screens) is clickable, allowing users to show/hide the submenu by touching anywhere within the area?

https://i.sstatic.net/03po7.png My goal is to make the entire navbar area touchable, rather than just having a button. I believe this can be achieved by adjusting the default Bootstrap 4 navbar settings: HTML: <nav id="menu-navbar" class="navbar navb ...

Get the download link for myFileName.myFileType from the UIWebView

I need my UIwebview to initiate a download of a file when its link is clicked. Currently, it just displays the content of the file, which is in JSON format. Despite registering the mimetype and trying to add download="target.myfiletype" to the anchor t ...

Scroll upwards within a nested div

Is there a way to smoothly animate the content of the inner div upward without requiring any button clicks? Also, is there a method to trigger an event once the animation has completed? ...

Page not reaching the very top when scrolled

Having a puzzling issue that's got me stumped. Currently working on my professor's website at jurgec.net. The problem is specific to the mobile version of the site. Whenever clicking on a link like "I am an undergraduate student," scrolling down ...

Establishing a connection between JavaScript and MySQL within an HTML document

Recently, I started using node.js's node-mysql driver for MySQL and decided to write this piece of code: var mysql = require("mysql"); var connection = mysql.createConnection({ host : "localhost", user : "root", ...

The onclick event in JavaScript is unresponsive on mobile devices

Our website is powered by Opencart 1.5.6.4 and the code snippet below is used to add items to the shopping cart. <input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?&g ...

Tips for managing the fixed position property in CSS when dealing with overlapping elements

This image displays the overlap of two divs. One div contains a table with two buttons floating on the right, while the other div features an image. Here, the overlapping issue does not occur. I have detailed my problem with overlapping above and I aim t ...

Assistance needed in creating a MVC3 and Razor 2-level horizontal navigation menu

I am attempting to create a 2-level horizontal menu, similar to the one featured on the following site: TV.Com Despite searching on google, I am struggling to put it all together. Below is the sample code I am working with: <div id="divNav"> <u ...

Tips for incorporating inline images with gatsby-image

Seeking Solution In my quest to query and showcase images with a maximum width of 350px, I am hoping to have them displayed inline-block for tablets and larger screens. Ideally, each image would sit next to one another and wrap if they exceed the parent d ...