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 date in that column and the dropdown arrows should align horizontally so that they appear stacked on top of each other.

When I replace table elements with spans throughout, it resembles image 1. However, when using tables as shown in my code below, it looks more like image 2. The issue arises where the dropdown arrows seem to shift leftward. How can I move them to the right while still being able to use table elements for cell positioning? Appreciate any guidance on this matter.

<div class="col-md-12 dropdown" id="premiumsDropdownBtn">
   <div class="dropdown-toggle dropend" role="button" id="dropdownMenu2" data-bs-toggle="dropdown">
      <table>
         <td>Dental: </td>
         <td class="position-relative">PLAN A<span class="dropdown-arrow"></span></td>
         <td style="text-align: right;">1/1/2023 - NA</td>
      </table>
   </div>
   <div class="dropdown-toggle dropend" role="button" id="dropdownMenu3" data-bs-toggle="dropdown">
      <table>
         <td>Dental: </td>
         <td class="position-relative">PLAN B</td>
         <td style="text-align: right;">1/1/2023 - NA</td>
      </table>
   </div>
   <div class="dropdown-toggle dropend" role="button" id="dropdownMenu4" data-bs-toggle="dropdown">
      <table>
         <td>Vision: </td>
         <td class="position-relative">TEST PLAN C<span class="dropdown-arrow"></span></td>
         <td style="text-align: right;">1/1/2023 - NA</td>
      </table>
   </div>
   <div class="dropdown-toggle dropend" role="button" id="dropdownMenu5" data-bs-toggle="dropdown">
      <table>
         <td>Vision: </td>
         <td class="position-relative">LONGER PLAN D<span class="dropdown-arrow"></span></td>
         <td style="text-align: right;">1/1/2023 - NA</td>
      </table>
   </div>
</div>

Answer №1

It appears that there are a few errors in your code. Here is the revised version:

  • Wrap the content of each dropdown toggle in a <tr> (table row) element.
  • Place the <tr> inside a <table>.
  • Make sure that each <td> (table cell) is enclosed within a <tr>.

<div class="col-md-12 dropdown" id="premiumsDropdownBtn">
    <div class="dropdown-toggle dropend" role="button" id="dropdownMenu2" data-bs-toggle="dropdown">
        <table>
            <tr>
                <td>Dental: </td>
                <td class="position-relative">PLAN A<span class="dropdown-arrow"></span></td>
                <td style="text-align: right;">1/1/2023 - NA</td>
            </tr>
        </table>
    </div>

    <div class="dropdown-toggle dropend" role="button" id="dropdownMenu3" data-bs-toggle="dropdown">
        <table>
            <tr>
                <td>Dental: </td>
                <td class="position-relative">PLAN B<span class="dropdown-arrow"></span></td>
                <td style="text-align: right;">1/1/2023 - NA</td>
            </tr>
        </table>
    </div>

    <div class="dropdown-toggle dropend" role="button" id="dropdownMenu4" data-bs-toggle="dropdown">
        <table>
            <tr>
                <td>Vision: </td>
                <td class="position-relative">TEST PLAN C<span class="dropdown-arrow"></span></td>
                <td style="text-align: right;">1/1/2023 - NA</td>
            </tr>
        </table>
    </div>

    <div class="dropdown-toggle dropend" role="button" id="dropdownMenu5" data-bs-toggle="dropdown">
        <table>
            <tr>
                <td>Vision: </td>
                <td class="position-relative">LONGER PLAN D<span class="dropdown-arrow"></span></td>
                <td style="text-align: right;">1/1/2023 - NA</td>
            </tr>
        </table>
    </div>
</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

Ways to determine if an element has exceeded its container's boundaries

After creating the codesandbox, I have developed a webapp that heavily relies on user input. To keep it simple for demonstration purposes, I am displaying various authors on an A4 formatted page using `page` and `font-size` with the `vw` unit for responsiv ...

Highlighted Navigation Options

When visiting , take note of the top navigation bar. The background color on this page is white, but as you navigate to other pages, the tab changes to a different color. How can you modify this behavior and change the class? Is PHP or jQuery necessary f ...

Limit Range of jQuery UI Slider Button

How can I modify the jQuery UI slider range to keep the button within the slider div and prevent it from overlapping as shown in the screenshots below? https://i.sstatic.net/odG3o.png https://i.sstatic.net/aiGxr.png ...

Aligning the canvas resolution to match the video resolution for superimposition purposes

Within a div, I have both a canvas and a video element: <div id="videos"> <canvas id="my-canvas"></canvas> <video id="remote-video" autoplay></video> </div> Below is the css styling for both elements: #my-canv ...

`To transfer the selected radio button value to a different form field using jquery, follow these steps.`

I need to set either the value no or 1 for the input field name="auth[]" below. <td> send <input type="radio" name="authorized[]'.$c.'" id="send'.$c.'"value="1" checked> </td> <td> no <input label=" ...

Varying pagination styles found in completed Bootstrap 5 implementation

After compiling my Bootstrap 5 sources, I noticed a difference in the style of pagination. Here is the result: https://i.sstatic.net/zjtQC.png However, when I link Bootstrap 5 via CDN, the pagination appears like this: https://i.sstatic.net/wtGEx.png I ...

What is the method for fetching a WebElement with a specific CSS attribute using JavascriptExecutor?

Currently, I am faced with a situation in which I need to locate a WebElement based on its CSS property, specifically the background-color. I successfully crafted the JQuery script below to pinpoint the element using the firefox console: $('.search-b ...

Currently, my goal is to create a functional copy button through the use of JavaScript

I've been attempting to create a basic copy button using JavaScript, but I keep encountering an error. TypeError: null is not an object (evaluating 'myInp.select') Whenever I click the copy button, My code looks like this: <!DOCTYPE htm ...

:after pseudo class not functioning properly when included in stylesheet and imported into React

I am currently utilizing style-loader and css-loader for importing stylesheets in a react project: require('../css/gallery/style.css'); Everything in the stylesheet is working smoothly, except for one specific rule: .grid::after { content: ...

Closing notifications in Bootstrap 5.1 with the help of Ajax

I am utilizing bootstrap 5.1 alerts to display custom messages after an Ajax call. I also want the ability to dismiss the alert as necessary, which can be done with a dismiss button provided by bootstrap. Below is the PHP code I am using : <div class=& ...

Bullet-point Progress Indicator in Bootstrap

Seeking guidance on how to create a Bootstrap progress bar with dots incorporated, similar to the image linked below. Any tips or resources where I can learn more about this technique? https://i.stack.imgur.com/BF8RH.jpg .progress { width: 278px; he ...

Issue with rollover button function in Firefox and Internet Explorer when attempting to submit

I have created a rollover submit button using HTML and JavaScript: <input type="image" id="join" name="join" src="images/join.png" value="join"> My JS code implements the rollover/hover effect: <script type="text/javascript" charset="utf-8"> ...

Adjust the size of a Highcharts chart before printing

I'm facing an issue with a chart that doesn't have a specified height or width. My goal is to print the graph in a taller and larger size when I click on the print button. I attempted to use setSize() function, but since there are no original di ...

What causes a custom element to suddenly crumble?

I am attempting to create a custom field that can display either an SVG or a Canvas, but the rendering is not as expected. I anticipate two boxes that are 400 pixels wide and 300 pixels high, however, they appear to collapse in an unusual manner. How can I ...

The process of inserting a CSS file into a CodeIgniter project

Hey there, I'm struggling to load a CSS file in Codeigniter. Can someone please guide me on how to do it? Below is an overview of the Codeigniter sample Directory Structure: views models controllers assets a) stylesheets b) javascript c) images Conf ...

Convert JSON data into an HTML table with custom styling

If you have a set of JSON data that you want to convert into an HTML table, you can use the following code: $.each(data, function(key, val) { var tr=$('<tr></tr>'); $.each(val, function(k, v){ $('<td>' ...

Styling with CSS: Using a Base64 Encoded Image in the Background URL

Can a Base64 encoded image be loaded as a background image URL without exposing the actual encoded string in the page source? For example, if a Node API is used to GET request at "/image", it returns the serialized Base64 data. res.json("da ...

Tips for preserving changes made to a jQuery script when the page is reloaded

Is there a way to retain jQuery script changes when the page is reloaded? I have a page where clicking on certain elements triggers events, and I want these changes to persist even after reloading the page, resetting only when the cache is cleared. I appre ...

Click the button to add content to the top section of the div using jQuery

Looking for some assistance with a web development issue I'm facing. Here's the scenario: I have two sections on my webpage - TOP and BOTTOM. In the bottom section, there are 3 list records each with a checkbox and button. What I need help with ...

Is it possible to use jQuery to load an HTML file and extract its script?

I have a navigation bar with five buttons. Whenever a button is clicked, I want to dynamically load an HTML file using AJAX that includes some JavaScript code. The loaded file structure resembles the following: <div> content goes here... </div& ...