Arranging the rows and columns of a table in optimal alignment

I am currently facing an issue with two tables. The first table consists of 2 rows and 4 columns, with the first column spanning 2 rows. However, in the visual representation, the last 3 columns are misaligned with the rows. How can this alignment be corrected?

Furthermore, the columns in this table have been set to equal sizes.

The second table also has 3 columns but multiple rows. It appears that the first 3 columns are compressed together. Could someone identify the problem? I suspect it may be related to my CSS.

HTML code for the tables:

<table class="equalDevide" cellpadding="0" cellspacing="0" width="100%" border="0">

Here is the HTML for the second column in the first row of the first table:

<td>
            <div id="positionAnchor">
                <img src="adele.jpg" alt="Adele">
                <div id="bottom">
                    <h4 class="topText">ALBUM</h4>
                    <h3 class ="topText">ADELE 21 COVER </br> ADELE</h3>
                </div></div>
        </td>

Second column in the second row:

<tr id="left-col">
            <td>
                <div id="caption-color">
                    <h3 id="active">Adele 21 Album</h3>
                    <p class="music-name"><span class ="glyphicon glyphicon-headphones"> Adele - Skyfall</span></p>
                </div>
            </td>

Below is the associated CSS:

#bottom{
    position: absolute;
    display: inline-block;
    bottom: 0px;
    left:0px;
}

#positionAnchor {
    position: relative;
    width:1px;
}

#caption-color{
    background-color: #212121;
    position: relative;
    display: inline-block;
    bottom: 0px;
    padding: 5px;
    float: bottom;
}

.equalDevide td { 
    width:25%; 
}

HTML code for the second table:

<table class="table">
        <tbody>
            <tr>
                <td  id="left-info">
                    <span class="glyphicon glyphicon-calendar"> 17 SEPTEMBER</span>
                </td>
                <td  id="left-info">
                    <span class="glyphicon glyphicon-music" > MARTIN GARRIX</span>
                </td>
                <td  id="left-info">
                    <span class="glyphicon glyphicon-map-marker"> NEW ORLEANS,LA</span>
                </td>
                <td id="buyNow">
                    Buy Now
                </td>
            </tr>

CSS for the second table:

table{
    border-collapse: collapse;
}
tr{
    background-color: #575757;
    border-top: 10px solid #383D3D !important;
}
td{
    border-left: 3px solid #383D3D !important;
    text-align: center;
}

Answer №1

Combine the #caption-color CSS with the positionAnchor CSS...

#positionAnchor {
    position: relative;
    display: inline-block;
    text-align:center; /* center the text */
}

The CSS rules for the second table are not as expected.

table{ ... define rules for the table element }
.table{ ... define rules for elements with class table }

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

I am experiencing an issue where my application, built using NodeJS, Express, and Javascript, is failing to insert form data into the database despite

I am facing a challenge with my app's MVC design pattern where I am unable to insert form information into the corresponding table in the database. Despite installing the body-parser package via npm, the form is not functioning as expected. Can anyone ...

Position divs to align text beside icons

I am currently working on a Bootstrap popover to display various pieces of information, each containing an icon and some text. Additionally, I am incorporating twig into this project. Here is the HTML structure: <span class="fa fa-user instructor-con ...

How can I use JavaScript api calls to retrieve an image url and insert it into an image tag in an

I have a JSON object that I need to use to retrieve images from a remote URL and display them in the img tag using API calls. The API link can be found at <div class="emoji"> <ul id="emojiz"></ul> <span style= ...

Issue with the Z-Index property not functioning as expected on unordered lists within a dropdown menu

I have a dropdown menu that opens to the left, but it is displaying underneath the content. I attempted adjusting the z-index of the content to 1 and the dropdown to 2, however, this did not resolve the issue. Here is a sample in jsFiddle: https://jsfiddl ...

Using jQuery to apply gradient fill to SVG elements

Is it possible to create a gradient fill in an SVG with two or three colors dynamically? Currently, filling an SVG path with just one color can be done easily. Radial gradients are an option but don't offer much flexibility as colors have to be define ...

Dynamic visuals created with Jquery and Ajax

While I'm not an experienced developer, I have managed to work with some small Jquery scripts. Lately, I've been struggling for the past month trying to figure out how to implement a specific functionality that I would like to incorporate. Does a ...

Leveraging HTML5 file uploads alongside AJAX and jQuery

While there are questions with similar themes on Stack Overflow, none seem to quite fit the bill for what I am looking for. Here's my goal: Upload an entire form of data, including a single file Utilize Codeigniter's file upload library So fa ...

Decrease the heaviness of a Glyphicon

How can I make Glyphicons appear lighter in weight? I have utilized the "ok" Glyphicon <span class="glyphicon glyphicon-ok"></span> which currently displays as follows: Is there a method to decrease the weight of the icon in order to create a ...

Is there a way to alter the color of options within a select tag when hovering the mouse over them

After searching through multiple websites, I couldn't find a solution on how to change the option background color on hover from blue to green. The screenshot provided below illustrates what I am requesting for in a clearer manner. I attempted to use ...

What is the best way to choose all <pre> tags that have just one line of content?

$('pre:contains("\n")') will target all <pre> elements that have one or more newlines. Is there a way to specifically select <pre> tags with no newline or only one at the end? Any shortcuts available? match <pre>A< ...

The exact problem with aligning the table

Below is a simplified version of my code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body style="font-size: 36px"> </body> </html> <html> ...

What are alternative methods for passing data to a template besides EJS?

app.get("/movies", function(req, res) { Movies.find({}, function (err, foundMovie){ if(err) { console.log(err); } else { res.render("movies/index", {movie_index:foundMovie}); } } }); I have written code to retrieve a movie and ...

Getting text between Span tags using Selenium in Python

Struggling to extract the name "Margaret Osbon" from the following HTML using Python and Selenium. Despite trying different techniques, the printed output always comes out blank. <div class="author-info hidden-md"> By (autho ...

Extract script from webpage using Python and Beautiful Soup

In the process of scraping 5 different shopping websites, I've successfully gathered valuable data from StackOverflow and YouTube. However, I have encountered a roadblock with one particular website. After utilizing various methods such as AJAX, Googl ...

Applying a class change in Vue.js upon mounting

How can I make a button element with a .hover property trigger the hover animation as soon as the page loads? I want to apply a class to the button when the page is mounted and then remove it later. What is the best approach for this? I considered using a ...

Issue with spacing in 3x3 photo rollover grid

I am currently working on a 3x3 grid layout featuring image roll overs. Within this layout, the three images on the second row are linked to pages on the website. My goal is to incorporate a 4px padding around all columns and rows, centered at 1024x600 on ...

Preventing Adjacent Text from Moving Due to a Floated i Element

I have a div with a bootstrap icon positioned at the top right corner. However, I want to center the text horizontally without shifting the position of the icon. Is there a way to achieve this? See my sample code here: https://jsfiddle.net/x1Lvyu6t/3/ ...

Is there a way to center the text at 0% using text-align in Bootstrap?

My progress bar, designed with Bootstrap, currently displays the text in a way that is not centered as desired. The issue I am experiencing is that the "0/0" text shifts to the left and using text-align: center; does not seem to resolve this alignment pro ...

How can PHP be utilized to dynamically add classes to <li> elements and alternate them after every third item

I'm trying to find a way to add a class to an unordered list and alternate that class after every third item. Here's the code I have so far: <?php $i=1; foreach($this->items as $item) : ?> <li class="<?php if ($i % 3 == 0) : ...

HTML does not support the use of certain symbols

Currently, I am in the process of designing a homepage for my school project. However, I have run into an issue. The content that I want to be displayed on my homepage is as follows: "Daudzspēlētāju tiešsaites lomu spēle (Massively Multiplayer Online ...