Designing a structured layout with div elements resembling tables within a Bootstrap 4 card

I'm struggling with formatting this card. My goal is to create two columns, one with the class col-xs-3 and the other with the class col-xs-9. The titles in the col-xs-3 column should align with the corresponding titles in the col-xs-9 column.

Unfortunately, I haven't been able to achieve this layout yet.

Here is a snippet of my current card layout. Can someone assist me with this issue?

.detail-titles {
  color: blue;
  border-right: 1px solid red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-lg-12 col-xl-12 ">

  
  <div class="card">
    <div class="card-body">
      <div class="container">
        <div class="row">
          <div class="col-xs-3 detail-titles">
            <p>1 title</p>
            <p>2 title</p>
            <p>3 title</p>
            <p>4 text</p>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-9 text-right">
            <p>1 title-match</p>
            <p>2 title-match</p>
            <p>3 title-match</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis accumsan, enim vel condimentum tristique, est lacus placerat risus, sed luctus nulla metus vitae eros. Vivamus dictum aliquam mauris eget consequat. Proin nec lorem a nisi tristique
              porta vitae vel quam. Sed est nisi, aliquam eu ligula sit amet, pulvinar finibus est. Curabitur lectus augue, fermentum et mauris eget, hendrerit sollicitudin nisi. Morbi in lacus ac sapien malesuada commodo ut a lectus. Integer at diam
              convallis, molestie sem sit amet, gravida lorem. Fusce sagittis ornare dui. Maecenas at vestibulum lorem, in sodales tellus. Nunc sed urna in nunc gravida fermentum id non diam. Mauris porttitor nisl sed quam commodo, sit amet ultrices dolor
              gravida. Donec imperdiet venenatis dui sit amet condimentum. Morbi vel nisi pellentesque, vulputate nibh a, ornare sem. Pellentesque tempus nisl quis rutrum hendrerit. Praesent eget massa nisl. Vestibulum elit tortor, mollis vitae orci eget,
              vestibulum iaculis sapien. Sed vulputate risus vel lectus congue, sit amet dapibus arcu commodo.</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

col-xs is not available in bootstrap4

To resolve this, remove the container(row) div from the parent

<div class="col-sm-9 text-right">

.detail-titles {
  color: blue;
  border-right: 1px solid red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-lg-12 col-xl-12 ">
  <div class="card">
    <div class="card-body">
      <div class="row">
          <div class="col-sm-3 detail-titles">
            <p class="border-bottom">1 title</p>
            <p class="border-bottom">2 title</p>
            <p class="border-bottom">3 title</p>
            <p class="border-bottom">4 text</p>
          </div>
          <div class="col-sm-9 text-right">
            <p>1 title-match</p>
            <p>2 title-match</p>
            <p>3 title-match</p>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis accumsan, enim vel condimentum tristique, est lacus placerat risus, sed luctus nulla metus vitae eros. Vivamus dictum aliquam mauris eget consequat. Proin nec lorem a nisi tristique
              porta vitae vel quam. Sed est nisi, aliquam eu ligula sit amet, pulvinar finibus est. Curabitur lectus augue, fermentum et mauris eget, hendrerit sollicitudin nisi. Morbi in lacus ac sapien malesuada commodo ut a lectus. Integer at diam
              convallis, molestie sem sit amet, gravida lorem. Fusce sagittis ornare dui. Maecenas at vestibulum lorem, in sodales tellus. Nunc sed urna in nunc gravida fermentum id non diam. Mauris porttitor nisl sed quam commodo, sit amet ultrices dolor
              gravida. Donec imperdiet venenatis dui sit amet condimentum. Morbi vel nisi pellentesque, vulputate nibh a, ornare sem. Pellentesque tempus nisl quis rutrum hendrerit. Praesent eget massa nisl. Vestibulum elit tortor, mollis vitae orci eget,
              vestibulum iaculis sapien. Sed vulputate risus vel lectus congue, sit amet dapibus arcu commodo.</p>
          </div>
        </div>
    </div>
  </div>
</div>

Answer №2

Only one 'row' element is necessary, even though you have two.

I have made a change from xs to sm in the bootstrap columns because you are using Bootstrap 4. Consider this: `col-xs-*` not working in Bootstrap 4

<div class="card">
    <div class="card-body">
        <div class="container">
            <div class="row">
                <div class="col-sm-3 detail-titles">
                    <p>1 title</p>
                    <p>2 title</p>
                    <p>3 title</p>
                    <p>4 text</p>
                </div>
                <div class="col-sm-9 text-right">
                    <p>1 title-match</p>
                    <p>2 title-match</p>
                    <p>3 title-match</p>
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis accumsan, enim vel condimentum tristique, est lacus placerat risus, sed luctus nulla metus vitae eros. Vivamus dictum aliquam mauris eget consequat.
                      Proin nec lorem a nisi tristique porta vitae vel quam. Sed est nisi, aliquam eu ligula sit amet, pulvinar finibus est. Curabitur lectus augue, fermentum et mauris eget, hendrerit sollicitudin nisi. Morbi in lacus ac sapien malesuada commodo ut a lectus.
                      Integer at  diam convallis, molestie sem sit amet, gravida lorem. Fusce sagittis ornare dui. Maecenas at vestibulum lorem, in sodales tellus. Nunc sed urna in nunc gravida fermentum id non diam.
                      Mauris porttitor nisl sed quam commodo, sit amet ultrices dolor gravida. Donec imperdiet venenatis dui sit amet condimentum. Morbi vel nisi pellentesque, vulputate nibh a, ornare sem.
                      Pellentesque tempus nisl quis rutrum hendrerit. Praesent eget massa nisl. Vestibulum elit tortor, mollis vitae orci eget, vestibulum iaculis sapien. Sed vulputate risus vel lectus congue, sit amet dapibus arcu commodo.</p>
                </div>
            </div>
        </div>
    </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

"Creating a user-friendly interface design with two separate divs, each showcasing a

I am looking to create a UI/UX design that includes a logo and two menus, one for language change and one for navigation. https://i.sstatic.net/Tb6zc.png My current approach involves two div elements: 1. The first div contains the image and language men ...

Utilizing Grunt bake to generate unique files with various content from a single template

Is it possible to use bake to display multiple contents within the same styled template? https://github.com/MathiasPaumgarten/grunt-bake For example, if my template looks like this: <div style="background-color:red"> </div> And I have Cont ...

arranging a collection of images based on their values in increasing order

cardShop is a container with various images, each with its own unique ID and value attribute. These values consist of two numbers separated by a comma, such as 2000,500 or 1500,200. My goal is to sort these images in ascending order based on the first numb ...

Tips for effectively showcasing the counter outcome amidst the increase and decrease buttons

Currently, I am in the process of learning Angular and have created a component called quantity-component. Within the quantity-component.component.html file, I have implemented 2 buttons for increment (denoted by +) and decrement (denoted by -). The decrem ...

Incorporating a unique font into your SAPUI5 application

While experimenting with an expense app design, I decided to incorporate a receipt-like font for a unique look and feel. After discovering the FakeReceipt font, I placed my woff and woff2 files in the same directory as my style.css file, and it worked like ...

In need of assistance with adding a divider within a box using HTML/CSS

As a beginner, I may have messy code but I'm working on creating a job search page with a bar displaying the results like this: I've almost got it, except I can't figure out how to add that divider between PREV, 1 to 100, and NEXT. My curre ...

Tips for sending information to a modal window

I need to transfer the userName from a selected user in a list of userNames that a logged-in user clicks on to a twitter bootstrap modal. I am working with grails and angularjs, where data is populated using angularjs. Set-Up The view page in my grails a ...

The dropdown menu displaying the img-dropdown-content with a display set to none is not functioning as anticipated

Attempting to hide drop down menu with img-dropdown-content but it's not working, possibly being overridden by another element - only using html and css I have experimented with visibility: hidden; both with and without !important as well as display: ...

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' ...

Learn the process of generating sequential heading numbers for topic headings in each HTML document using DTA or XHTML

I attempted to include hierarchical numbers for topic headings in dita2xhtml_eclipsehelp.xsl. (DITA OT HTML output) However, I am facing difficulty in producing numbers similar to the following in each html file: 1 heading text 1.1 heading text 1.1.1 Head ...

Tips for preventing a bootstrap modal from being dragged beyond its parent container

I need help figuring out how to prevent my bootstrap modal from being dragged outside of its parent container. Is there a way to constrain the modal within its parent? $(document).ready(function() { ShowValidationResult(); }); function ShowValidation ...

How can we use Bootstrap to ensure that items in a div are aligned horizontally on larger devices and vertically on smaller devices?

I am currently working on creating a div that contains some information, similar to the layout used on the Coinbase website. However, I am encountering issues with styling as I want this div to be responsive - horizontally aligned on larger devices and ver ...

Enhance Vaadin 14: Automatically adjust TextArea size when window is resized

Using Vaadin 14.1.19 in a project called "My Starter Project," I attempted to create a TextArea that supports multiple lines. Initially, everything seemed fine, but upon resizing the TextArea, it failed to adjust the number of visible lines. Here is the co ...

What is the best way to create some distance between a div element and the bottom of the body?

Hello, I am attempting to center a div within my body. The div has a minimum height of 400px, but its size can expand based on the content it holds. When I add more content to the div, it grows accordingly, but it ends up touching the bottom of the div. I ...

Is it possible to ensure that an <a href stays at the top of the page with jQuery

I have implemented the supersized plugin to display a rotating fullscreen image background that includes <a> tags. However, since it is positioned behind my site content, the images cannot be clicked. I am curious if there is a way to bring an < ...

Click event for jQuery horizontal accordion

I'm attempting to create a simple horizontal accordion-style element. My setup includes three 'banner' divs and three 'area' divs. Ideally, when I click on a banner, the corresponding area should animate - expanding in width to au ...

Dealing with network issues when submitting a form

Is there a smooth way to handle network errors that may arise during the submission of an HTML form? It is important for me not to have the browser cache any information related to the form, but I also want to ensure that the user's data is not lost i ...

Developing an interactive selector within the on() event handler

My goal is to utilize the on() event for managing dynamically created code. It functions properly when the selector is hardcoded in the on() event. However, I aim to enable it to select different elements depending on which box they choose. $("body").on( ...

Alphabetic divider for organizing lists in Ionic

I am currently working with a list in ionic that is fetched from a controller and stored in localStorage. My goal is to add alphabetic dividers to the list, but I am facing some confusion on how to achieve this. Here is a snippet of the code: app.js $ion ...

javascript how to retrieve the custom attribute value of an HTML style

I am dealing with an HTML element that has some inline styles as well as a custom CSS property. I am able to access every style attribute except for my custom style property. Here is the code I am working with: <img id="myimg" class="ImgClass" style=" ...