What is the best way to enforce a left alignment for a menu?

I am looking to align the titles on the left side. I suspect that the issue lies in this particular line of code. Can someone help me identify which properties I should adjust to resolve this problem?

https://i.sstatic.net/XWCsd.png

Interestingly, the icons are correctly positioned within the layout.

CSS

.sidebar .nav-links {
    margin-top: 10px;
}

.sidebar .nav-links li {
    position: relative;
    list-style: none;
}

.sidebar .nav-links li a {
    display: flex;
    justify-content: space-between;
    text-decoration: none;
    transition: all 0.4s ease;
    border-bottom: 1px solid #ccc;
    padding: 13px 0;
}

.sidebar .nav-links li a.active {
    background: #081D45;
}

.sidebar .nav-links li a:hover {
    background: #081D45;
}

.sidebar .nav-links li i {
    min-width: 60px;
    text-align: center;
    font-size: 18px;
    color: #fff;
}

.sidebar .nav-links .item {
    text-transform: uppercase;
}

.sidebar .nav-links li i.fa-chevron-down {
    right: 1rem;
    left: auto;
}

.sidebar .nav-links li.active i.fa-chevron-down {
    transform: rotate(180deg);
}

.sidebar .nav-links li.active i {
    color: white;
}

.sidebar .nav-links li a .links_name {
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    white-space: nowrap;
}

HTML

<ul class="nav-links">
  <li *ngFor="let menu of menus; let i = index" [class.active]="menu.active">
    <ng-container>
      <a class="item" (click)="selectMenu(menu)">
        <i [class]="menu.iconClass"></i>
        <span class="links_name">{{ menu.name }}</span>
        <i class="fa fa-chevron-down"></i>
      </a>
      <ul
        class="submenu"
        #submenu
        [ngStyle]="{ 'height': menu.active ? submenu.scrollHeight + 'px' : 0 + 'px' } "
      >
        <li *ngFor="let submenu of menu.submenu">
          <a routerLink="{{ submenu.url }} "
            ><span class="links_subname">{{ submenu.name }}</span>
          </a>
        </li>
      </ul>
    </ng-container>
  </li>
</ul>

If you would like to see a live demonstration, please visit this Stackblitz link => Stackblitz.

Your assistance and insights are greatly appreciated!

Answer №1

Here is a suggested solution for you to try:

.sidebar .nav-links li a {
    display: flex;
    justify-content: start;
    text-decoration: none;
    transition: all 0.4s ease;
    border-bottom: 1px solid #ccc;
    padding: 13px 0;
}


.sidebar .nav-links li i.fa-chevron-down {
    right: 0;
    position: absolute;
}

Answer №2

.sidebar .nav-links li a {
  display: flex;
  justify-content: start;
  text-decoration: none;
  transition: all 0.4s ease;
  border-bottom: 1px solid #ccc;
  padding: 13px 0;
}

a.item i.fa-chevron-down {
  position: absolute;
  min-width: 30px;
  right: 4px;
}

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 position an element at the center using Flexbox技

Having some difficulty centering an element in my code using flexbox. It seems to work for everything else, but not here. Any suggestions or ideas? .answer { text-shadow: 0 0 2px gr; display: flex; justify-content: center; border-radius: 5px; ...

Executing a function when a dropdown in Bootstrap is expanded and closed

How can I use JavaScript to execute a function when clicking on a notification button in a Bootstrap navbar to expand the dropdown, and then close the dropdown when clicking it again? I have tried selecting the dropdown and modifying the click function, b ...

The sticky positioning in <table> element fails to function properly in Firefox as well as Chrome version 58

Visit the website Scroll down until you see the "The First 40 Elements" table. Continue scrolling to reach the end of the page. In Chrome version 57, the table header stays sticky, but in Chrome 58 it does not. Interestingly, the table header also does n ...

Arranging components in a horizontal layout on Jquery mobile

I'm completely new to Jquery mobile and I'm having trouble getting these elements aligned. Here's my code, but I need the two icons to line up horizontally with the caption "Heading". <h3>Heading</h3> <img src="../re ...

Choose the option for overseeing safaris

Hello there! I need some help with Safari. Can you please guide me on how to disable the arrows? https://i.stack.imgur.com/1gzat.png ...

There seems to be an issue with the on() function in jQuery when using mouseover

I am trying to implement a small popup box that appears when I hover over some text, but for some reason it's not working as expected. Can someone please help me troubleshoot this issue? My goal is to display the content from the "data-popup" attribut ...

What is the best way to stop div animations when clicking with jQuery?

Upon loading the page, a div animates automatically. There is also a button present. When the button is clicked, I would like to create a new div and animate it the same way as the first one. However, when this happens, the position of the first div also ...

Tips for distinguishing the beginning and ending points of wrapped text in the Firefox browser

Within my work, I am utilizing a contentEditable span where I aim to position an element with position: absolute on the same line as the cursor. However, issues arise when text wrapping occurs - causing abnormal behavior at the start and end of wrapped lin ...

The horizontal scrolling with overflow-x is not functioning correctly as it is displaying the scrollbar for the vertical

I am perplexed as to why I am unable to scroll horizontally to view the other pink thumbs. Despite adding an overflow of scroll-x to the thumbs container, which should theoretically allow horizontal scrolling, it only seems to scroll vertically. Could som ...

CSS allows for the creation of fixed bars that remain at the top of the

I am looking to create a fixed bar that is off-center with a scrolling background. The code I have so far either places the bar on the surface but fixes it to the background, or it positions the bar beneath the image and fixes it to the window - neither ...

Activate the div when hovering over the span

Experiencing an issue with triggering a visible div while hovering over a span. Here is the code structure: <ul class="products"> <li> <a href="somelink"> <img src="some image"> <div class="overlay"> Some Text</div> & ...

Navigating with a Stuck Navigation Bar Using BootstrapretaF

My website has a sticky navbar with a dropdown menu that allows users to jump to different sections of the page. However, I've noticed that when I navigate to a new section, the navbar covers part of the content at the top. After inspecting the navbar ...

Preventing default CSS styles in ASP.NET: A step-by-step guide

When working with multiple CSS files for different themes, I noticed that the Login Page is calling one extra CSS file. However, during runtime, some classes from the default CSS are still being used. How can I resolve this issue? ...

New button attribute incorporated in AJAX response automatically

data-original-text is automatically added in ajax success. Here is my code before: <button type="submit" disabled class="btn btn-primary btn-lg btn-block loader" id="idBtn">Verify</button> $(document).on("sub ...

What is a creative way to design a mat-radio-group without traditional radio buttons?

I am looking to create a component that offers users a list of selections with the ability to make only one choice at a time. The mat-radio-group functionality seems to be the best fit for this, but I prefer not to display the actual radio button next to t ...

disable full page scrolling on iOS devices

Can you achieve elastic scrolling for a single absolutely positioned div in Mobile Safari without causing the entire page to move up and down? Check out this basic example that illustrates the problem: <!doctype html> <html> <head> ...

Is it possible to change the background color of a Bootstrap button using CSS overrides?

Desired Outcome https://i.sstatic.net/EjEXG.gif Actual Result https://i.sstatic.net/BmXYG.gif The goal is to toggle the red-background class, so that when hovering over the button-bullet, its background-color changes to #FCC1C5. Avoiding the use of .b ...

Is there a way to utilize either css3 or css in order to change the icon displayed on a button

Currently, I am working on a button that contains a span element. I am interested in finding a way to change the background of the span when the button is clicked and have it remain changed. Is there a way to achieve this using CSS only? I am aware that ...

What could be causing the height of my Bootstrap row with Snook's Simple jQuery Slideshow to be zero?

I recently added Snook's Simple jQuery Slideshow feature to my Bootstrap 3 website. If you want to see it in action, click on this link: Oddly enough, the row containing the slideshow is not displaying correctly as its height is registering at 0. Th ...

Avoiding Navbar Link Clicks due to Z-Index

Is it possible for the z-index or positioning of an element to hinder a user from clicking on a navbar link? When I visit my website , I find that I am unable to click on any of the links in the navigation bar. Could this be due to the z-index or position ...