Variations in functionality within the Google Chrome browser

This is the content of my HTML document.

<BODY>
    <button id="b1" onclick="load()">Play</button>
    <canvas id="c1" onclick="f_clicked(this.id,1)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>
    <canvas id="c2" onclick="f_clicked(this.id,2)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>
    <canvas id="c3" onclick="f_clicked(this.id,3)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>
    <br>
    <canvas id="c4" onclick="f_clicked(this.id,4)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>
    <canvas id="c5" onclick="f_clicked(this.id,5)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>
    <canvas id="c6" onclick="f_clicked(this.id,6)">
        Your browser does not support the HTML5 canvas tag.
    </canvas>

</body>

Here is the CSS code:

body{
    background - color: gray;
}
button {
    height: 40px;
    width: 40px;
}
canvas {
    width: 100px;
    height: 100px;
    border: 1px solid #000000; display:none; }

The desired layout should be as follows: The first row contains the first 3 canvas elements and the second row contains the next 3. There should be a gap of 20px between each canvas element.

Browser Behavior: In Chrome, there is a collapse between the second row elements, while Firefox displays the expected results for both rows.

Can anyone explain why Chrome behaves differently in this case?

Answer №1

Make sure to eliminate the

</br>

Instead, enclose your 2 sets of canvas within divs, since they are display: block; the second set will be pushed below, replicating the behavior of a
, but without the same amount of spacing.

<body>
<div id="set-one">
<button id="b1" onclick="load()">Play</button>
<canvas id="c1" onclick="f_clicked(this.id,1)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
<canvas id="c2" onclick="f_clicked(this.id,2)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
<canvas id="c3" onclick="f_clicked(this.id,3)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
</div>
<div id="set-two">
<canvas id="c4" onclick="f_clicked(this.id,4)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
<canvas id="c5" onclick="f_clicked(this.id,5)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
<canvas id="c6" onclick="f_clicked(this.id,6)">
    Your browser does not support the HTML5 canvas tag.
</canvas>
</div>

This approach will give you the 2 sets of canvas you desire/require, likely without any additional space in between.

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

How to center align a fixed div position

I am looking for a way to center align a fixed position div on my page. In the past, I have been able to achieve this with absolutely positioned divs using a specific technique. left: 50%; width: 400px; margin-left: -200px; However, this method does no ...

Preserving Scroll Location Through Back Button Usage and Ajax Manipulation of the Document Object Model

Currently, I am incorporating a feature where results are loaded in using ajax with an infinite scroll. However, there is an issue when a user clicks on an item in the list and navigates away from the page - upon returning by clicking the back button, they ...

Jquery Parallax causing scrolling problems across different browsers

Could you please take a look at the following link in both Chrome and Firefox? I am encountering some unusual issues. Primary Concern The scrolling function works smoothly in Firefox, but it seems to be malfunctioning in Chrome. Secondary Problem Whe ...

Learn how to increase a value with each dynamically clicked button in JavaScript

Whenever I try to increment the value by clicking the like button, it seems to be increasing but not in sync with the actual button count. How can I fix this issue? index.html <div class="row"> <div class="col-md-4"> ...

Refreshing a page using AJAX form functionalities

After spending some time searching, I am unable to find a satisfactory solution to my issue. I have a "finance" tracker that includes hidden divs which are displayed using jQuery when the corresponding button is clicked. Additionally, I have an Asset Track ...

Angular: Discovering and retrieving all images within a div container

I am on a quest to locate all image tags within a specific div. These image tags are nested within paragraph tags inside the div. I attempted to create a plunkr to accomplish this task, but unfortunately, I haven't had any success yet. If anyone is ab ...

CSS effect() Practical duration

I have successfully implemented a CSS filter to blur an element, however, I am looking for a way to make the blur ease in smoothly. I'm not sure which css property controls this easing effect? Initially, I tried using transition: 1s; but that ended u ...

Learning how to implement the selection tag to upload data to a SQL database using PHP

As a coding beginner, I've been tackling a project involving data insertion into an SQL server with PHP. My current struggle lies in the process of inserting data and capturing select tag objects as variables. I keep encountering Undefined Index error ...

What is the process for obtaining Style.css, additional CSS, and JavaScript files from a live single page website?

I am currently facing a challenge with a live single page website where I need to make some fixes. Unfortunately, I am unable to access the Style.css file, along with other css and javascript files. Although I managed to save the html file by using Ctrl+s, ...

Implement a smooth transition effect when changing the image source

I am currently working on enhancing a Squarespace website by adding a new image fade-in/fade-out effect when the mouse hovers over one of three buttons. The challenge I'm facing is that the main static image is embedded as an img element in the HTML r ...

Issues with PHP and mySQL search functionality

<?php $username = "root"; $password = ""; $hostname = "localhost"; $db_handle = mysql_connect($hostname, $username, $password) or die ("Could not connect to the database"); $selected= mysql_select_db("login", $db_handle); ...

I am experiencing issues with a few of my design choices not functioning correctly

I am facing issues with some of my styles. I have put in a lot of effort, but there seems to be a problem with my menu. The last part of my CSS is not functioning correctly. When hovering over the menu content, I want it to turn black and... #site_menu { ...

CSS issue: Font size

Can someone help me out with a CSS issue that has been tripping me up? I've been working with CSS for three years now, and this particular problem is stumping me. I have defined some styles in my CSS file that should be applied to the content of my w ...

Load JavaScript files in order within the <body> tag and trigger a callback function when all files have

Currently, my website (which is actually a Cordova/Phonegap app) has the following scripts in the <head>: <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="appPolyfills.js"></script> ...

Could the reason behind the malfunctioning of the bootstrap tabs be due to my CSS files?

I'm looking to implement Bootstrap tabs in the sidebar of my website, but I'm running into an issue where the tabs aren't functioning properly within the sidebar-parsel-liste class. If I place the tab tags outside of this class, everything w ...

What is the best way to create a div that horizontally scrolls and contains multiple other div elements?

I've set up a div that contains other divs, including images and text. My goal is to make the main div scrollable horizontally while aligning the inner divs using inline-block. However, when I apply: overflow-x: scroll; The main div ends up with tw ...

Making jQuery work: Utilizing tag replacements

My current code is: this.html(this.html().replace(/<\/?([i-z]+)[^>]*>/gi, function(match, tag) { return (tag === 'p') ? match : '<p>'; return (tag === '/p') ? match : '</p& ...

Creating a Gradient Effect for Partial Next Slide on Slick Slider using Bootstrap 4

I am currently designing a responsive carousel using Bootstrap-4 and slick.js. With the center-mode enabled, I noticed that it shows a partial next slide. I am interested in adding a gradient to this partial next-slide, but I am uncertain about how to acco ...

"Exploring the vibrant world of colors with Colorbox: a

In one of my projects, I am utilizing colorbox to create a video gallery. One feature I am trying to implement is to display the video description underneath each video when opened in the colorbox modal. Currently, here is what I have: <script> $( ...

Combining LESS with cultural designations

Currently working on a multi-lingual website project and facing the challenge of switching out CSS based on different languages. I am passing the culture code into the page and exploring ways to use it to reference specific selectors for each language. H ...