Creating a flexible Tic Tac Toe board using only HTML and CSS without any JavaScript

I'm currently tackling an HTML layout challenge that involves creating a responsive Tic Tac Toe board using only HTML and CSS, without any JavaScript. This is how I have structured the layout of the board:

<div class="board">
    <div class="lines">
        <div class="line">
            <div class="cell">
                <div class="cell-content"></div>
            </div>
            <div class="cell">
                <div class="cell-content"></div>
            </div>
            <div class="cell">
                <div class="cell-content"></div>
            </div>
        </div>
        <div class="line">
            <div class="cell">
                <div class="cell-content"></div>
            </div>
            <div class="cell">
                <div class="cell-content"></div>
            </div>
           <div class="cell">
                <div class="cell-content"></div>
           </div>
       </div>
       <div class="line"></div>
            <div class="cell"></div>
               <div class="cell-content">&<>/div>
          </div>
       </div>
   </div>   
</div> 

Here is the corresponding CSS code:

.board {
    position: relative;
    height: 100%;
    width: 100%;
    border:1px solid black;
    box-sizing:border-box;
}
.board:before {
    content:"";
    display: block;
    padding-top: 100%;
}
.lines {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}
.line {
    width: 100%;
}
.cell {
    float: left;
    width: 33.3333%;
    border:1px solid black;
    box-sizing:border-box;
}
.cell:before {
    content:"";
    display: block;
    padding-top: 100%;
}
.cell-content {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

In this setup, I haven't specified any sizes besides width: 33.3333%. The height of the board and cells is determined using the Height equals width with pure CSS technique.

Overall, everything looks good. However, there's one issue - sometimes the combined widths/heights of the board cells are less than the overall width/height of the board. This results in a visible gap between the last cell border and the board border. While I can replicate it in Chrome or Firefox, it doesn't seem to occur in Internet Explorer. Is there a way to resolve this?

You can check out a demo on jsFiddle (the red line indicates the gap).

UPDATE: After further examination, I realized that the issue also occurs in IE. Still unsure why I hadn't noticed it earlier.

Answer №1

One quick solution is to set the overflow property of the .line Elements to auto;

.line {
    overflow: auto;
}

After making this adjustment, you'll be all set! :D

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

Operating PHP program from html on Beaglebone Black Rev C Debian

I've created a JavaScript program that utilizes node.js to manage GPIO from an IO.html page to the beaglebone. I simply initiate the JavaScript with "node myscript.js". Now, I'm looking to incorporate a PHP file that will store data from the IO. ...

The front page is excessively tall, lacking any rationale for its lengthy design

I have noticed that my website, located at , is unexpectedly long. I am puzzled as to what could be causing this issue and although I know how to correct it, I am curious to find out what exactly is making the page scroll so far down. It's quite stra ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

What is the best way to show a border-left outside of the list marker in Internet Explorer 8?

I have a numbered list that I would like to add a left border to. <ol class="steps"> <li>item 1</li> <li>item 2</li> <li>item 3</li> <ol> .steps {border-left: 5px double #7ab800;} When viewing in Fir ...

Tips for preventing a React component from scrolling beyond the top of the page

I am looking to achieve a specific behavior with one of my react components when a user scrolls down a page. I want the component to reach the top of the page and stay there without moving any further up. Here is an Imgur link to the 'intranet' ...

What is the best method for obtaining table structure using Bootstrap dropdowns?

[Using span instead of table element][1] [Using the table element][2] Currently working with Bootstrap 5, my goal is to have a fixed-width table in place of dropdown menu items. I aim to position the text in the 3rd column all the way to the right. The da ...

Align labels on top and inputs at the bottom using Bootstrap

I'm facing an issue with alignment in my form using Bootstrap 4.4. Whenever a select element is included, it disrupts the layout by breaking the alignment of labels and inputs on the same row. Is there a way to always keep the labels at the top and t ...

Transitioning Between Div Elements Using Jquery

I am stuck with the following HTML code: <section> <div id="first"> ---content </div> <div id="second"> ---content </div> </section> When the page loads, the second div and its contents are not visible (I'm uns ...

Using CSS to style the footer with a body height set to 100%

I am currently working on an angularJS web app with a basic template structure: <html> <head> <link rel="stylesheet" href="style.css" /> </head> <body id="top"> <!-- Templates with vi ...

Uploading files in chunks using a combination of HTML, JavaScript,

I've been using a file chunking solution (although I can't recall its origin), but I've made some modifications to suit my requirements. Most of the time, the file uploads successfully; however, there are instances where an error occurs. U ...

The Bootstrap 5 navigation bar does not extend to the full width of its parent

While working on a Bootstrap navigation inside a container, I encountered an issue where the navigation bar was not expanding to match the width of the container. It seemed like the padding had to be manually adjusted to fit properly. Below is the code sn ...

Clearing selections from a multiple-choice input field

I am seeking to implement a delete feature in a multi-select element similar to the functionality seen here on stackoverflow when selecting multiple tags for a question. Once an item is selected, I would like to display a close icon next to it so that user ...

Dynamic search form technology

My HTML view includes a search form and AJAX code to handle the form request $(document).ready(function() { console.log('Ready'); $('.search-wrapper').on('click', '#find-dates', function(a) { a. ...

Is it possible to use CSS to target the nth-child while also excluding certain elements with

How can I create a clear break after visible div elements using pure CSS? Since there isn't a :visible selector in CSS, I attempted to assign a hidden class to the div elements that should be hidden. .box.hidden { background: red; } .box:not(.hid ...

Enhance the functionality of a directive by incorporating the ui-mask directive

Recently, I implemented a custom directive for an input field that adds a calendar icon with a datepicker to the input. I have used this directive in various sections of my application and now I am interested in incorporating ui-mask - another directive I ...

retrieve the timestamp when a user initiates a keystroke

Seeking assistance from the community as I have been struggling with a problem for days now. Despite searching on Google and Stack Overflow, I haven't found a solution that works for me. My web application features an analog clock, and I need to capt ...

Obtain span value using a CSS selector in Python

I need help extracting the value of a span using a CSS selector soup = BeautifulSoup("<body><main><div class='rentalprice'><span>3.000</span></div></main></body>") pagecontent = soup.find( ...

Is there a way for me to customize the appearance of the Material UI switch component when it is in the checked

I am seeking to customize the color of the switch component based on its checked and unchecked state. By default, it displays in red. My goal is to have the "ball knob" appear yellow when the switch is checked and grey when it is not. This styling must be ...

Adjust the size of an image based on the smaller dimension utilizing CSS

Allowing users to upload images that are displayed in a square container in the UI presents challenges. The uploaded images can vary in size, aspect ratio, and orientation, but they should always fill the container and be centered. To address this issue, ...

Enclose each instance of "Rs." with <span class="someClass">

I'm facing an issue with the currency symbol "Rs." appearing in multiple places on my website. I want to enclose every instance of this text within <span class="WebRupee">. However, if it's already wrapped in <span class="WebRupee">, ...