Is there a way to align all the values in the center of the row, while ensuring that the div above the row does not have the same width as the row below it? If so, how

 <!DOCTYPE html>
        <html lang="en">

        <head>
          <meta charset="UTF-8">
         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <style type="text/css">
         ul {
          list-style-type: none;
          margin: 0;
          padding: 0
         }
         li{
            height: 64px;
            background-color:pink;
         }
         .a{
            height: 64px;   
         }
         .ab{
                display: flex;
                direction: row;
            align-items: center;
         }
         }
         .b{
            display: flex;
            direction: row-reverse;
            align-items: center;
         }
         .secondli{
            margin-top: 20px;
         }
        </style>
          <title>Document</title>
        </head>

        <body>
          <div class="container" >
            <div class="row">
              <div class="col-md-6 col-6" >
               <p>mwiiwiw</p>

              <ul>
                <li>
                    <div style="width: 100%">
                        <span>Xyz</span>
                        <span>sjfoeij</span>
                    </div>
                <div class="row a">

               <div class="col-12 col-md-8  ab" style="background-color: aqua;">
                <span class="b">ABC</span>
            </div>
                <div class="col-12 col-md-4 b"style="background-color: yellow;" >
                <span>11</span>
            </div>
        </div>
        </li>
         <li class="secondli">
                <div class="row a">
               <div class="col-12 col-md-8  ab" >
                <span class="b">ABC</span>
            </div>
                <div class="col-12 col-md-4 b" >
                <span>11</span>
            </div>
        </div>
        </li>
        </ul>
        </body>

        </html>

How can I display all the values at the center of the row?And the div with spans value Xyz is not taking width same as row below it.And also the second row is not taking width same as row above? How can I achieve that using bootstrap and Css. Can we add two li and a row inside li or we will have to add container as well inside?

Answer №1

<!DOCTYPE html>
<html lang="en>

<head>
  <meta charset="UTF-8>
         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0>
  <style type="text/css>
 div{
   height: 80px;
   text-align: center;
   padding-top: 30px;
 }
</style>
  <title>Document>
</head>

<body>
  <div class="container" >
    <div class="row">
      <div class="col-sm-6" >
       <p>mwiiwiw</p>

       <div class="row">
        <div class="col-sm-8" style="background-color: aqua;">
          <span class="b">XYZ</span>
        </div>
        <div class="col-sm-4 b"style="background-color: yellow;" >
          <span>Sjfoeij</span>
      </div>
      </div>
    <div class="row">
      <div class="col-sm-8" style="background-color: blue;">
        <span class="b">ABC</span>
      </div>
      <div class="col-sm-4 b"style="background-color: red;" >
        <span>11</span>
    </div>
    </div>
    <div class="row">
       <div class="col-sm-8" style="background-color: aqua;" >
        <span class="b">ABC</span>
      </div>
        <div class="col-sm-4" style="background-color: yellow;" >
        <span>11</span>
    </div>
</div>
</body>

</html>

Answer №2

Here is the code snippet as requested by @irkhaladkar:

ul {
      list-style-type: none;
      margin: 0;
      padding: 0
     }
     li{
        /*height: 64px;
        background-color:pink;*/
     }
     .pink{background:pink;}
        .h-64{height:64px}
        .a{
        height: 64px;   
     }
     .ab{
            display: flex;
            direction: row;
        align-items: center;
     }
     }
     .b{
        display: flex;
        direction: row-reverse;
        align-items: center;
     }
     .secondli{
        margin-top: 20px;
     }
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

      <div class="container" >
        <div class="row">
          <div class="col-md-6 col-6" >
           <p>mwiiwiw</p>

          <ul>
            <li>
                <div class="row pink">
                    <span class="col-12 col-md-6">Xyz</span>
                    <span class="col-12 col-md-6">sjfoeij</span>
                </div>
            <div class="row h-64">

           <div class="col-12 col-md-6  ab" style="background-color: aqua;">
            <span class="b">ABC</span>
        </div>
            <div class="col-12 col-md-6 ab"style="background-color: yellow;" >
            <span>11</span>
        </div>
    </div>
    </li>
     <li class="secondli">
            <div class="row h-64 pink">
           <div class="col-12 col-md-6 ab" >
            <span class="">ABC</span>
        </div>
            <div class="col-12 col-md-6 ab" >
            <span>11</span>
        </div>
    </div>
    </li>
    </ul>

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

tips on locating the next immediate downloadable cell in a table

My table includes cells with colspan and rowspan attributes. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <table border=1 id="mytable" > <tr><td>A1</td> <td> A2 < ...

Manipulate your table data with jQuery: add, update, delete, and display information with ease

When adding data dynamically to the table and attempting to edit, the checkbox value is not updating. This issue needs to be resolved. You can view the code in action on jsFiddle here on JSFiddle ...

Is It Always Necessary to Specify a Width and Height for an Image?

Is it necessary to specify both the Width and Height of an image on a webpage for consistent display across all browsers, or is specifying just one sufficient? While it may appear fine on certain browsers, I want to double-check for accuracy. Appreciate ...

Tips for properly sizing 13 images in Next.js

I've been facing some challenges while working on a responsive website, particularly with getting the sizing right. When viewing my image on mobile, everything looks good: https://i.sstatic.net/gNm14.png However, when I switch over to desktop view, ...

Placing a pair of labels onto a bootstrap form while ensuring column alignment

I'm trying to format a form according to my UI/UX specifications, where there is a parent label and two sub-labels. Can this be achieved using Bootstrap? https://i.stack.imgur.com/J8wJZ.png However, I'm struggling to align the columns and rows ...

Hiding my valuable content with a sneaky CSS nav bar

My current issue involves the nav bar overlaying my content Here is a link to the problem for reference I am seeking advice on how to resolve this issue, as I'm unsure of what steps to take The nav bar functions properly in responsive/mobile mode, ...

Using Angular/Typescript to interact with HTML5 Input type Date on Firefox (FF)

Are there any Angular/Typescript projects that are completely built without relying on third-party libraries? I am encountering problems with Firefox and IE11. It works fine on Chrome where the value can be read, but the calendar does not display when us ...

Obtain the in-flow position of a DOM element

alert("Incorrect (red): " + document.getElementById("target").getBoundingClientRect().top); alert("Proper (blue): " + document.getElementById("wrapper").getBoundingClientRect().top); #target { transform: translate(20px, -20px) rotateZ(20deg); backgroun ...

Elevate your web design by transitioning from Bootstrap 4 to Bootstrap 5

Should I upgrade a large project from Bootstrap 4 to version 5? Will it require extensive changes in each file? After updating my project, many components have stopped working: Dropdowns Accordions and more Is this a common issue experienced by everyo ...

Pulling out a particular row from an HTML table with the help of HTML::TreeBuilder

I am a beginner in perl programming and I am facing a major challenge. I need to parse an HTML file that contains a single table, and extract a specific row based on one of its column entries. Here is a snippet of the HTML file: many previous rows descri ...

Creating visually appealing definition lists

My goal is to customize the appearance of a shopping cart that is created by a rigid system where I cannot modify the html code. The categories list is generated in the following manner: <dl id='dlCatLvl1' class='clsCatLvl1 clsOffCat1&ap ...

Can a horizontal navigation bar be designed to span the full width of the page without relying on a table?

I'm trying to create a horizontal navigation menu with variable width buttons that spans the full width of the containing div. I was successful in achieving this by using a table, as demonstrated in this example. The table cells adjust their size base ...

Maintaining Aspect Ratio and Adding Letterboxes with Next.js Image

In my Next.js app, there is a section dedicated to displaying selected photos from a gallery. It's crucial for this area to maintain a fixed size of 566px*425px as users navigate through images or when a photo is loading. While the layout is responsiv ...

Launch a nearby hyperlink in a separate tab

I am currently facing an issue where all the URLs in a Text get linked as Hyperlinks. However, when a user types www., the browser interprets it as a local URL and associates the link with the application's URL. Does anyone know how to open a local U ...

What is the best way to make an element disappear 5 seconds after the mouse has stopped hovering

#section1 { display: block; } #section2 { display: none; } #container:hover > #section2 { display: block; } <div id="container"> <div id="section1">Section1</div> <div id="section2">Section2</div> </div> ...

The scrollbar track has a habit of popping up unexpectedly

Is there a way to prevent the white area from showing up in my divs where the scroll bar thumb appears? The issue seems to occur randomly on Chrome and Safari. https://i.sstatic.net/jFzTf.png This is the div in question .column-content{ height:60vh; ...

I am currently having issues with a PHP script I wrote for sending email, as it is

After creating a form and implementing a PHP script to send an email upon form submission, I encountered an issue where the "Thank you" message was displayed on a different HTML page, but the email wasn't sent to my account. I uploaded the files to t ...

unable to retrieve element values using class names

I have created multiple h1 elements with the same class names listed below. <h1 class="h1">One</h1> <h1 class="h1">Two</h1> <h1 class="h1">Three</h1> <h1 class="h1">Four</h1> I have also added a button that ...

Locate specific elements on a webpage without scanning through the entire content

Is there a way to optimize the performance of getElementsByTagName("td") so it doesn't search the entire document? I'm experiencing long wait times for results. Here is an excerpt from my code: $ie.Document.getElementsByTagName("td") | ? {($_.c ...

What is the best way to add data-content to hr:after using JavaScript?

Adding style to an element in javascript can be simple. For example: myElement.style.color = "red"; However, what if I wanted to achieve something like this: hr:after { content: "myRuntimeValue" } Is there a way to do this using javascript? ...