Home > Back-end >  How to align icons to the right
How to align icons to the right

Time:04-19

I have a menu with a bulleted list, I would like to align an arrow type icon to the right, but the alignments are not done exactly.

Here is an image below of my problem...

image

I think the problem is here?

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

Here is a reproduction of the project.

HTML

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

CSS

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

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

.sidebar .nav-links li a {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    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;
}

Thank you a lot for your help.

CodePudding user response:

Use this:

.sidebar .nav-links li a {
  display: flex;
  justify-content: space-between;
}

Remove the min-width: 60px; on the .navlinks li i and set flex-basis: 20%;.

  • Related