What's causing the misalignment in the top row?

What could be causing the misalignment of cells in the first row? JSfiddle link

Here is the code snippet:

 .box3 {
   margin: auto;
   width: auto;
   height: 300px;
 }
 .tb2 {
   border-collapse: collapse;
   color: black;
   text-align: center;
   margin-top: 10px;
   margin-left: 10px;
   width: 950px;
   height: 300px;
   display: inline-block;
   overflow: auto;
 }
 .tb2 > tbody > tr > th {
   border: 1px solid black;
   background-color: black;
   color: white;
   font-weight: bold;
 }
 .tbd {
   width: auto;
   height: 330px;
   background-color: white;
   color: black;
   overflow: auto;
   display: block;
 }
 .tbd > tr > td {
   border: 1px solid black;
   width: 5%;
   height: 100%;
 }
<div class="box3">
  <table class="tb2">
    <tr>
      <th></th>
      <th>Day</th>
      <th>Theory Class</th>
      <th>Practical Class</th>
      <th>English Class</th>
      <th>Start Time</th>
      <th>End Time</th>
      <th>Decription</th>
      <th>Checked</th>
      <th></th>
      <th></th>
      <tr>
        <tbody class="tbd">
          <tr>
            <td>1</td>
            <td>Mon</td>
            <td>XXXXXXXXXXXX</td>
            <td>XXXXXXX</td>
            <td>XXXXXXX</td>
            <td>hh:mm</td>
            <td>hh:mm</td>
            <td>XXXXXXXXXXXX</td>
            <td>Yes</td>
            <td>Update</td>
            <td>Delete</td>
          </tr>
        </tbody>
  </table>
</div>
</div>

What adjustments need to be made to align the columns of the first row with the bottom column? Apologies for any language barriers.

Answer №1

By utilizing the following CSS classes:

.tb2 { display: inline-table; }
.tbd { display: table-row-group; }

You can avoid tabular displays and opt for a more streamlined approach.

.box3 {
  margin: auto;
  width: auto;
  height: 300px;
}
.tb2 {
  border-collapse: collapse;
  color: black;
  text-align: center;
  margin-top: 10px;
  margin-left: 10px;
  width: 950px;
  height: 300px;
  display: inline-table;
  overflow: auto;
}
.tb2 > tbody > tr > th {
  border: 1px solid black;
  background-color: black;
  color: white;
  font-weight: bold;
}
.tbd {
  width: auto;
  height: 330px;
  background-color: white;
  color: black;
  overflow: auto;
  display: table-row-group;
}
.tbd > tr > td {
  border: 1px solid black;
  width: 5%;
  height: 100%;
}
<div class="box3">
  <table class="tb2">
    <tr>
      <th></th>
      <th>Day</th>
      <th>Working Class</th>
      <th>Start Class</th>
      <th>End Class</th>
      <th>Start Time</th>
      <th>End Time</th>
      <th>Note</th>
      <th>Checked</th>
      <th></th>
      <th></th>
    </tr>
    <tbody class="tbd">
      <tr>
        <td>1</td>
        <td>Mon</td>
        <td>XXXXXXXXXXXX</td>
        <td>XXXXXXX</td>
        <td>XXXXXXX</td>
        <td>hh:mm</td>
        <td>hh:mm</td>
        <td>XXXXXXXXXXXX</td>
        <td>Yes</td>
        <td>Update</td>
        <td>Delete</td>
      </tr>
      [Additional table rows here]
    </tbody>
  </table>
</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

Is it possible for Angular's ngStyle to accept multiple functions? If not, what is the alternative solution?

Can multiple conditions be added to different attributes with ngStyle? Is it possible to change text color and background color based on specific JSON values using ngStyle? About the Project: I am currently working on creating a tab bar that resembles a ...

Adjust the size of the child div to fit the remaining space within the parent div

I'm dealing with a situation where there are two child divs inside a parent div. The first child div takes up 32% of the width, while the second child div takes up 68% of the width. If I were to set the display of the first child div to "none", how ca ...

Error: The number of format specifications in 'msgid' and 'msgstr' does not match. One fatal error was found by msgfmt

I encountered an error with Django-Admin that reads: "Execution of msgfmt failed: /home/djuka/project_app/locale/eng/LC_MESSAGES/django.po:49: number of format specifications in 'msgid' and 'msgstr' does not match. Msgfmt found 1 fatal ...

When utilizing the ::first-letter pseudo-element on <sub> and <sup> tags

Why is the <sub> and <sup> not supporting the ::first-letter CSS pseudo-element? Any solutions? p:first-letter, sub:first-letter, sup:first-letter { color: red; font-weight: bold; } <p>This text contains <sub>subscript</su ...

When scrolling a semi-parallax effect in a resized window, I notice a calming presence of empty white

I recently acquired a WordPress website from its previous owner, and I'm encountering an issue with the parallax section at the top. It seems to be scrolling at a slightly slower pace than the rest of the page. I've tried adjusting the width and ...

Create a hyperlink in an HTML document that links back to itself using

I am looking to add multiple links on a page, each with different GET parameters. However, I want the links to redirect to the current page. <a href="CURRENT_PAGE?param1=123&param2=345">Link1</a> <a href="CURRENT_PAGE?param1=234&pa ...

Is it possible to close the menu by clicking outside a div or letting it disappear on mouseout after a set period of time?

When visiting a website, you may notice menus that display sub-menus when hovered over. These menus and sub-menus are created using div elements, with the sub-menus hidden initially using style.display = none; The issue arises when a sub-menu is opened an ...

Leverage CSS variables in Firefox to customize your webpage

I am currently developing a comprehensive CSS tabs navigation system. Here is the link to what I'm trying to achieve: http://jsfiddle.net/7fZnn/1/ However, I want to avoid using inline CSS to position my tabs. In my search for alternatives, I came ac ...

Bootstrap: White space can be seen on the right side of the mobile screen, with an incomplete nav bar

My website, built with Bootstrap, functions properly on desktop and in landscape mode on mobile. However, it encounters issues in portrait mode on mobile where white space appears on the right side and part of the navigation bar is missing. Below is the c ...

What is the best way to hide the input field when there are multiple parent classes present?

I am currently implementing dynamic fields with jQuery and everything is functioning correctly. The problem arises when I attempt to remove these fields. After searching on Google and browsing past questions on StackOverflow, I noticed that everyone seems ...

Adding an Image to an InfoWindow on Google Maps

Hey there! I'm attempting to insert an image into a Google Maps infoWindow. Here's my code snippet: var ContactUs = function () { return { //main function to initiate the module init: function () { var map; $(document). ...

Tips for dynamically updating the div class based on the model's value

How can I dynamically change the CSS class of a bootstrap element based on a value? I would like to display a div in green if the value is "OK" and red otherwise. If status = "OK", it should look like this: <div class="small-box bg-green">, else < ...

Having issues with the <ul> tag not displaying correctly

I'm currently working on implementing a side navbar for my website, but I've run into an issue with spacing. In the demo linked in my fiddle, you'll notice that the <ul> element inside the receiptDropDown class doesn't push the k ...

Stop the div from automatically scrolling to the top when the home page is refreshed

As a beginner in javascript, I am currently working on my project. I have two pages set up: home.php and data.php. In home.php, here is the code that retrieves data from data.php and refreshes it every 3 seconds: <div id="show"></div> ...

Is there a way to retrieve the day of the week based on the date provided by the user

function retrieveWeekday() { var input = document.getElementById("input"); } <form> <input type="date" placeholder="dd:mm:yy" id="input"/> <input type="button" value="get weekday" onclick="retrieveWeekday()"/> ...

Retrieving the ID value and activating a click function for each link sharing a common class using jQuery

I'm facing a challenge in enabling the click function for every link with the same class name and unique id. Currently, the click function is only working on the first link, but there could be any number of links - 1, 2, 3, or more... To tackle this ...

Maximize the YouTube video for full screen viewing

Take a look at the code snippet from our page here: <div className={styles.videoPreview}> <iframe src={`${videoData[router.locale]}?autoplay=0`} title="Flytime" ...

Tips for customizing the md-select icon

I work with the angular-material framework and specifically utilize its <md-select/> component. I am interested in styling its icon: https://i.stack.imgur.com/g4pu1.png In the past, we would modify its css by targeting the class .md-select-icon, ...

Tips for aligning a custom icon to the left in a Jquery mobile header

I have successfully implemented a custom icon in the header, but it is currently displaying in the center. How can I adjust it to be positioned on the left side instead? <div data-role="header" data-theme="a"> <h3> ...

I am facing issues with getting my slideshows to work on localhost using node

After careful positioning of my divs using position: relative; for the slideshow and position: absolute; for containers, I am facing an issue. Despite trying to fix it based on similar questions posted by others, the slideshow is not functioning properly. ...