CSS accurately manages nested spans within lists

Link to Image

Image URL

The problematic area is the one inside the red square. The CSS classes being used are as follows:

.overflowHidden{
  overflow: hidden;
 }
.floatLeft{
  float: left;
}

.floatRight{
 float: right;
}

.floatAuto{
 float: auto;
}
.alignLeft {
 text-align: left;
}

.alignRight {
 text-align: right;
}

.alignCenter {
   margin-left:auto;
   margin-right:auto;
}

.alignJustify{
  text-align: justify;
}

.summaryListStyle{
    /*padding-left: 25%;*/
    list-style-position: outside;
 }

Here is how the markup looks like:

<h6 class = "alignLeft">Price Calculation:</h6>

          <ul class = "alignJustify">
            <li class="summaryListStyle">
              <span class="floatAuto alignLeft">{{ car.basemodel.name }}:</span>
              <span class="floatRight">{{ car.basemodel.price }} €</span>
            </li>

            <li class="summaryListStyle">
              <span class="floatAuto alignLeft">{{ car.edition.name }}:</span>
              <span class="floatRight">{{ car.edition.price }} €</span>
            </li>

            <li class="summaryListStyle" *ngFor="let extra of car.edition.extras">
              <span class="floatAuto alignLeft">{{ extra.name }} (belongs to edition):</span>
              <span class="floatRight">{{ extra.price }} €</span>
            </li>

            <li class="summaryListStyle" *ngFor="let extra of car.extras">
              <span class="floatAuto alignLeft">{{ extra.name }}:</span>
              <span class="floatRight">{{ extra.price }} €</span>
            </li>
          </ul>

          <div *ngIf="discount != 0.00">
            Prices for optional extras are reduced by {{ discount }}%.
          </div>
          <div class="summaryTotalPriceStyle exposedVerticallyTop">
            Total Price: {{ price }}    €
          </div>

I experimented with various combinations of the CSS classes mentioned above on the HTML elements, some worked better than others, but none was able to solve the issue completely. Regardless of the zoom level, there was always a problem. I believe this issue is related to the use of the float property, and unfortunately, I couldn't find an alternative way to move the SPAN elements inside the LI elements to the right. The text-align property didn't work either, as it didn't shift the content further to the right.

Answer №1

Check out the code snippet below and share your thoughts

.panel{
  width: 270px;
  background:grey;
  padding:15px;
}
ul{
  padding-left:50px;
}
ul li{
  margin-bottom:5px;
  list-style-position: outside;
}
ul li .content{
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
ul li > .content span:first-of-type{
  max-width:80%;
}
ul li > .content span:last-of-type{
  white-space:nowrap;
}
<div class="panel">
  <ul>
    <li>
      <div class="content">
        <span>Text 132456:</span>
        <span> 26 €</span>
      </div>
    </li>
    <li>
      <div class="content">
        <span>Lorem ipsum 123465:</span>
        <span>25 000 €</span>
      </div>
    </li>
    <li>
      <div class="content">
        <span>Lorem ipsum lorem ipsum lorem lorem:</span>
        <span> 659 €</span>
      </div>
    </li>
  </ul>
</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 automatically adjust the Total functional value whenever the dropdown selection is modified

I have a main table where I need to calculate the sum of "functional," "repair," "condemn," and "stole" for the items currently displayed. My issue is that even after applying filters, it still returns the total sum of all items, including those not displ ...

Floating Action Button is not properly attached to its parent container

When developing my React Js app, I decided to utilize the impressive libraries of Material UI v4. One particular component I customized is a Floating Action Button (FAB). The FAB component, illustrated as the red box in the image below, needs to remain p ...

What are some ways to shift all content (whether relative or absolute) downward?

If I have a webpage containing content positioned relatively and absolutely, along with scripts and various styles applied. Is there a universal method to move down the entire page content by 50px, creating an empty space at the top of the page? The solut ...

Design all buttons, except for the two specific buttons

.button , button{ border:solid black 2px !important; } Using this code, I have added a border to all buttons. But now, I need to exclude the buttons "searchsubmit" and "single_add_to_cart_button" from having a border. How can I achieve that? ...

Having difficulty getting my ASP telerik menu to function properly

After researching numerous threads on how to apply a personalized design to a telerik menu on my website, I have reached out for assistance. Even though some may not be familiar with the specifics, I am in urgent need of help with my current coding. In my ...

Use CSS to align one item to the left and center the rest on the page

Is there a way in CSS to achieve the following layout: a single block element anchored to the left side of the page the other elements centered on the page (not centered in relation to the remaining space) If there isn't enough space for this layout, ...

What is the best way to adjust a Checklist's width to match the width of its parent Dropdown in Dash Plotly?

At the moment, I am facing an issue with setting the width of a checklist from Dash Core Components to match the width of the dropdown menu it is placed in. Here's a glimpse of how it appears currently: https://i.sstatic.net/mjzAd.png Below is the P ...

Showing a cell border when a radio button is chosen

I am working with a table that contains input/radio buttons, and I am trying to figure out how to apply a border to a specific cell when the user selects the radio button within it. This will give the appearance of the cell being selected. I am not sure ho ...

Bootstrap 4's column ordering feature is malfunctioning

<div class="container"> <div class="row"> <div class="col-lg-8 col-md-12 order-2">1 </div> <div class="col-lg-4 col-md-12 order-1">2 </div> </div> </div> I need to change the orderi ...

Using CSS, you can utilize a three-dot pattern to create a unique X

Hey there! I've got a menu with three dots that animate, and when I click on them, I want them to transform into an X shape. You can check out the demo here: demo Here's the HTML: <div class="dots"> <div class="dot"></div> & ...

Square Division, width set to match 100% of the height

I have been attempting to create a square shape that is responsive, with the width determined by the height of the element (100%). I personally think achieving this using CSS alone is not possible. The goal is for the square's width to match its heig ...

What is the best method for resizing individual SVG elements using jQuery or JavaScript?

A unique effect on my webpage involves an SVG comprised of scattered squares that enlarge when the user scrolls past a specific point. However, there is a problem with the scaling process which results in a horizontal scroll bar appearing. This occurs beca ...

Tips on solving the Navigation bar burger problem with HTML and CSS

## I am having trouble making my navigation bar responsive using HTML and CSS as the navigation burger does not appear in mobile view ## To take a look at my code on jsfiddle, click here: [jsfiddle] (https://jsfiddle.net/abhishekpakhare/nxcdso7k/1/ ...

Ways to emphasize specific sections of the navigation bar

I am currently in the process of coding my own portfolio as part of my UX/UI program. My navigation bar is styled using the CSS code below: .nav-links { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-column-start: span; list-style ...

utilize javascript to style iframe from an external domain without access to its DOM structure

I have two websites, example.com and example1.com. I'm trying to display the content of example1.com within an iframe on example.com. For instance: Add this code to example.com: <iframe src='http://example1.com'> Then add the follow ...

When resizing the browser window, this single horizontal page website does not re-center

I am in the process of creating my very first one-page horizontal website using jQuery and the scrollTo plugin. This site consists of 3 screens and initially starts in the center (displaying the middle screen). To achieve this, I decided to set the width o ...

Toggle the visibility of a hidden div by clicking a button

After spending several days working on this project, just when I thought it was perfect, I had to completely restructure the entire page. Now I'm feeling stuck and in need of some help. The issue is that I have three images with buttons underneath eac ...

Navigating through pages using << >>, Previous, and Last buttons while preventing infinite scrolling

This particular code snippet is designed to generate a new page for every set of 8 div elements. pageSize = 8; showPage = function(page) { $('.line-content').hide(); $('.line-content:gt('+((page-1)*pageSize)+'):lt('+(p ...

Is the jQuery mobile theme "scope" not available, or is it hidden somewhere I haven't noticed?

When you're in the process of downloading a jQuery UI theme, there is an option to specify a "CSS Scope". If you input something like #my-app in the CSS Scope field, then all CSS rules will be prefixed with #my-app, restricting the application of tho ...

The flexibility of the flex-wrap property does not extend to affect nested elements

Check out this example first: http://jsfiddle.net/8ofrs0y7/14/ <div class="flex-group"> <ul class="flex-container red"> <li class="flex-item"&g;1</li> <li class=&qu ...