Tips for organizing table rows and columns without any overlapping intersections

I need help designing my table so that the intersections do not have crossed borders. Here is the CSS code I am using for my table:

table {
    border-collapse: collapse;
}
table td, table th {
    border: 1px solid black;
}
table tr:first-child th {
    border-top: 0;
}
table tr:last-child td {
    border-bottom: 0;

}
table tr td:first-child,
table tr th:first-child {
    border-left: 0;    
    border-right: 0;
}
table tr td:last-child,
table tr th:last-child {
    border-right: 0;
    border-left: 0;
}
.product_column {
padding: 3px;
margin-right: 5px;
margin-left: 5px;
}

I want to achieve a design where the borders align without crossing at the intersections, similar to the image below:

The following code will display the products in the table based on each if condition:

<?php if($colunmNumber =0)
    echo('<tr><td>');
    else 
    echo('<td style="text-align:center;">');
    $colunmNumber = $counter % $columns;  
?>
<div class="product_column" >

    <div class="product_image"><?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
        //some php code
    </div>
    <div class="product_title"   >
    //some php code
    </div>
</div>

If using tables alone does not resolve this issue, I am open to suggestions such as adding div elements or drawing lines with spans. However, I am unsure how to implement these solutions while maintaining the loop function that retrieves product information.

Thank you for your assistance

Answer №1

Incorporating this layout in a table structure might be easier, but the same design principles can be applied using div elements as well.

Given the complexity of the code involved, I have provided an example for you to reference: http://jsfiddle.net/5WzVV/

<table>
<tr>
    <td class="r"></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td class="c"></td>
    <td class="e">A</td>
    <td class="c br"></td><td class="c"></td>
    <td class="e">B</td>
    <td class="c br"></td><td class="c"></td>
    <td class="e">C</td>
    <td class="c"></td>
</tr>
<tr>
    <td class="r"></td>
    <td class="bb"></td>
    <td></td><td></td>
    <td class="bb"></td>
    <td></td><td></td>
    <td class="bb"></td>
    <td></td>
</tr>
<tr>
    <td class="r"></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td></td>
    <td class="e">D</td>
    <td class="br"></td><td></td>
    <td class="e">E</td>
    <td class="br"></td><td></td>
    <td class="e">F</td>
    <td></td>
</tr>
<tr>
    <td class="r"></td>
    <td class="bb"></td>
    <td></td><td></td>
    <td class="bb"></td>
    <td></td><td></td>
    <td class="bb"></td>
    <td></td>
</tr>
<tr>
    <td class="r"></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td></td>
    <td class="e">G</td>
    <td class="br"></td><td></td>
    <td class="e">H</td>
    <td class="br"></td><td></td>
    <td class="e">I</td>
    <td></td>
</tr>
<tr>
    <td class="r"></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td><td></td>
    <td></td>
    <td></td>
</tr>
</table>

Additionally, include the following CSS:

td.e { // styling for product cells
    width: 100px;
    height: 100px;
    text-align: center;
    vertical-align: middle;
}
td.r { // spacing cell for rows
    height: 5px;
}
td.c { // spacing cell for columns
    width: 5px;
}
td.bb { // bottom border for first row of spacer cells
    border-bottom: 1px solid #000;
}
td.br { // right border for first column of spacer cells
    border-right: 1px solid #000;
}

Answer №2

If you want a visually appealing table layout, consider styling your rows using HTML and CSS. Here is an example of how you can do that:

<html>
<body>
<table>
    <tr>
        <td><img src="samplePic.jpg"</td>
        <td>
            <div style="float: left; background: url(vline.jpg) repeat-y top; width: 20px; height: 200px"></div>
        <td>
        <td><img src="samplePic.jpg"</td>
    </tr>
    <tr>
        <td>
            <div style="float: left; width: 167px; padding: 15px 0 15px 0; background: url(hline.jpg) repeat-x center;"></div>
        </td>
        <td>
            <div style="float: left; width: 20px;"></div>
        <td>
        <td>
            <div style="float: left; width: 167px; padding: 15px 0 15px 0; background: url(hline.jpg) repeat-x center;"></div>
        </td>
    </tr>
    <tr>
        <td><img src="samplePic.jpg"</td>
        <td>
            <div style="float: left; background: url(vline.jpg) repeat-y top; width: 20px; height: 200px"></div>
        <td>
        <td><img src="samplePic.jpg"</td>
    </tr>
</table>
</body>
</html>

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

Leveraging Excel VBA to manipulate the selection in a dropdown menu on a webpage

Is there a way to select a specific value using Excel VBA? <div class="drpCompanies"> <select class="selectBox homepage selectCompanies" style="padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px"> <op ...

Automatically conceal a div or flash message after a short period of time by utilizing CSS3 in a React

I am relatively new to the React environment and recently created a basic component for a bookmarking feature. Essentially, when the favourite icon is clicked, an ajax call is sent > a record is created in the database > on ajax success, a flash me ...

Is there a way to position these divs in a line using inline-block?

I need help aligning two divs with text differently - one to the top left and the other centered but not on the same line. Here's the layout I'm aiming for: ---------------------------------------------- |Backstage |Issue 4 | | ...

How can I change the displayed value of a 'select' element programmatically in Internet Explorer?

My interactive graphic has a drop-down menu implemented with a <select> element. Everything functions correctly, except when using Internet Explorer. The issue arises when attempting to programmatically change the selected value of the <select> ...

a versatile tool or JavaScript module for dissecting different HTML documents

Looking to develop a versatile wrapper or JS plug-in that can parse HTML content and locate tables within the files, allowing users to generate visual graphs like pie charts and bar graphs. The challenge lies in the fact that the HTML structure is not fixe ...

Controller for Ionic 3 styles and loading animations

What is the best way to eliminate these white spaces in our fullscreen mode? View the image here removeWhiteSpace() { let space = document.getElementById('white-space'); if (space) { space.style.display = 'none'; ...

conceal a component within a different container

Is there a way to hide or show an element within a container based on the hover state of another container? Here is an example of what I have tried so far: HTML5 <div class="left-menu-container"> <div class="left-menu-inner-container"> ...

What is the process for designing a unique page in Wordpress with a custom stylesheet?

I'm a beginner with wordpress and I'm facing some challenges. I have 4 custom page templates that I need to create: Home, Portfolio, About, Contact. Each of these new pages requires a unique CSS file. I have enqueued my script portfolio.css lik ...

Utilize a counter to iterate the name repeatedly

echo "<td>".'<input type="text" name="date_from" class="datepicker"/>'."</td>"; Is there a way to utilize a counter to repeat the name attribute and then store it using $_POST[]? ...

Adjust the width of the dropdown list to be distinct from the width of the dropdown button

My goal is to create a dropdown where the width of the button is different from the width of the list. I am aware that we can adjust the widths using inline styling like style={{ minWidth: '200px' }}. Now, I want to set the width of the dropdown ...

Utilizing jQuery to extract data from a text file and manipulate the text content

As a newcomer to jQuery, I am currently working on creating a graph using Highcharts. I have set up a function that refreshes every 5 seconds when the page loads. Within those 5 seconds, my goal is to add a new point to each series in the chart. While add ...

Transfer dynamically generated table data to the following page

Seeking guidance on a common issue I'm facing. I am creating a table using data from Firebase upon page load, and I want users to click on a row to view specific details of that item. It may sound confusing, but it will make more sense with the code p ...

Discover the art of implementing linear gradient backgrounds in Tailwind css effortlessly

Is there a way to incorporate this specific color scheme into my background? linear-gradient(355.45deg, #FFFFFF 11.26%, rgba(255, 255, 255, 0) 95.74%) I have knowledge on how to implement this color using regular CSS, but I'm curious about how it can ...

angular literal containing a strike tag

I need help with inserting a string into a button using Angular literal, along with striking out the string based on a condition. button {{(players > 2) ? 'Start' : '<strike>Cannot start</strike>'}} The desired appearan ...

Guide on creating a JQM website with a stunning image carousel

I've experimented with several image carousels for my mobile sites, but none of them are delivering the results I seek. What I'm looking for is something similar to this site: If you view the above link on a mobile device, you'll notice th ...

The size of the card image and content area will remain constant based on the specified percentage

Looking for some guidance as I am still learning. I need the card below to have a fixed width of 38% for the image area and 62% for the content area, regardless of the size of the content (the height can increase if there is more text). In the image above ...

Having trouble loading CSS in an express view with a router

I am encountering an issue where I am unable to load my CSS into a view that is being rendered from a Router. The CSS loads perfectly fine for a view rendered from app.js at the root of the project directory. Below is my current directory structure, node_ ...

Enclose a text line within a flexible div container

I've encountered an issue with my CSS: I have a dynamic div containing a single line of text that needs to wrap every time the width of the div resizes to a smaller size. The challenge lies in having the text inside a table, serving as a directory fo ...

What is the best way to incorporate an image using <ul> type formatting?

Appearance <style> ul{ list-style-image: url('../8iAbk7rjT.png'); } </style> Development <ul> <asp:DataList ID="dd" runat="server"> <ItemTemplate> <li><a href="/Pages/index.aspx?cate ...

Performing Jquery functions on several elements at once

Looking at the code snippet below, there are two buttons and an input in each container. The input calculates and adds up the number of clicks on the 2 buttons within the same container. However, it currently only works for the first container. How can thi ...