CSS positioning causing HTML elements to not align to the right

I am currently working on aligning my items list to the right side of the webpage. Additionally, I would like to incorporate a vertical thin separator between the left and center data structure (hierarchy) and the items list on the right.

Here is the code in Right.component.html :

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="header-divider">
  <ul class="selection-list">
    <li *ngFor="let item of getSelections()">
      <button class="btn" (click)="deselect(item)" *ngIf="item.selected">
        <i class="fa fa-close"> {{ item.displayName }} </i>
      </button> 
    </li>
  </ul>
</div>

The styling for Right.component.css can be seen below:

.selection-list {
  list-style: none;
  margin-top: 5px;
  margin-bottom: 10px;
  line-height: 15px;
  font-size: 16px;
  color: #555;
  padding-left: 23px;
  text-transform: capitalize;
  right: 0;
}

.btn {
  border: none;
  padding: 0;
  background: none;
}

.header-divider {
  border-left:1px solid #38546d; 
  height:30px;
  position:relative;
  right:20px;
  top:10px; 
}

Currently, the items list appears below the hierarchy structure. What steps should I take to resolve this issue?

Answer №1

I typically opt for utilizing flexbox as it offers a straightforward solution to make use of all available space within a container. Here is my approach:

-----(Edited)-----

.flex-container {
    display: flex;
    height: 50px;
    border: solid 1px peru;
}

.sendToRight {
    margin-left: auto;
}
<div class="flex-container">
    <div class="PLCheck">
        fortuneSelect
    </div>
    <div class="sendToRight"> <!-- add class to div for manipulation -->
        rightSideComp
    </div>
</div>

In this scenario, the margin-left:auto property causes your .sendToRight div to align all the way to the right. Another alternative would be to utilize justify-content: space-between; in your container element to achieve the same outcome.

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

Utilizing URL parameters to send data to a Python CGI script

My goal is to pass parameters into my cgi script in order to display a specific post when a URL like www.helloworld.com/cgi-bin/world.py?post=101 is entered. I've attempted the following: link = '<a href="world.py?post=%s">test</a>& ...

Modify CSS and animation through jQuery with ASP.NET Field Validator

My current form contains around 10 controls, similar to the one below: <asp:TextBox ID="fullname" Width="200" MaxLength="50" runat="server"/> <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="contact" ControlToValidate="fullname" ID= ...

How come the values (quantity, cost, total) are being stored as zero upon submission, despite successfully transferring the values from the dropdown list to the input using JavaScript?

1. Explanation I am transferring the quantity and price of a product from a dropdown list to input fields. Then I calculate the sum of quantity * price in the third input field. If the quantity or price changes, the sum is automatically updated and disp ...

Choosing nested elements using CSS

Looking to target a specific element within a shared class, I'm struggling to find the right method to pinpoint the exact entry of this element. What I need to do is hide the current photo (pic2.jpg) and replace it with another image (pic3.jpg) in the ...

Navigating the itemlist HTML to extract and manipulate data in a Flask application

In my current project, I am attempting to retrieve a value from an array in Flask based on the user's selection. Additionally, I need to perform calculations on this value within Flask as well. Below is the code snippet: HTML Code: <div class="f ...

I successfully implemented an image tag using JavaScript, however, the image is not showing up on the webpage

When I click the add button in my PHTML file, I want to display an image of the selected fruit in a <div>. function moveoutid() { var sda = document.getElementById('availableFruits'); var len = sda.length; var sda1 = document.getElem ...

Pagination CSS may fail to function properly in Chrome after an AJAX call is returned

Having an issue with CSS not getting applied correctly after making an AJAX call with pagination. The problem seems to be specific to Chrome, as it works fine in Firefox. When inspecting the element, the CSS is present but not being applied properly until ...

PHP code for displaying images on the same level

Is there a way to position images side by side in PHP? For example: image image image image. Currently, with the following code: print "</h2><br><a href='form.php'><img src=***.jpg width=100 height=100 /><br> ...

What could be the reason for the function providing the value of just the initial input?

Why am I only getting "White" when I click on the colors? I can't seem to get any other values to appear on the screen. I'm confused about what mistake I might be making here. var x = document.getElementById("mySelect").value; function myFunc ...

Incorporating a unique BRAND logo as the header of an HTML page

https://i.sstatic.net/NV5BO.jpg Currently enhancing my front end development skills with HTML and CSS. I am trying to set up a menu bar with an image (header image) above it. However, I am facing issues in displaying the image stored in my images folder. ...

Troubleshooting issues with Bootstrap Nav-pills functionality

I have encountered an issue with my navigation structure. I am using a main nav-menu and a secondary nav-menu within the same div. When I first enter the page, the "Profile" tab is correctly active by default. Then, when I click on "Test", it becomes activ ...

Creating an unconventional sleek edge using CSS

By mistake, I accidentally created this unique border for an image that I surprisingly find quite appealing. Take a look at the code snippet below. The results are truly stunning! .smoothed { height: 140px !important; /* background: re ...

Maintain a specific number of decimal places while incrementing by a specific value

I've been developing a timer that specifically counts decimals in intervals of 1/30 (meaning the only decimals allowed are .x00, .x33, .x67). Everything has been running smoothly so far, but there's one thing that really bothers me - when the de ...

The page-break-inside property is essential for ensuring clean and organized printouts

Ensuring my application is compatible with all modern browsers is a top priority for me. It is essential that the minimum version of Internet Explorer supported is IE9. I recently constructed a simple print-friendly page containing a table which displays ...

Troubleshooting Media Queries in HTML, CSS, Bootstrap: Why Aren't They Applying as Expected?

I am still fairly new to web programming and just starting out with bootstrap. After creating a section of my page that worked well on larger screens, I realized it wasn't responsive enough on smaller devices. The height was set at 400px, causing hor ...

Elevating the table and row dimensions in Bootstrap

I'm currently working with Bootstrap 3 and I'm having trouble adjusting the height of my table and row. I've tried setting properties like line-height, but nothing seems to work. How can I increase the height? <style> div#descrip ...

Nodemon causing crashes in basic HTML pages

Having trouble getting a basic index.html page to work with nodemon. index.html <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> </hea ...

Define the width and height of images specifically for screens with a maximum device width using @media queries

Having some trouble with the sizing of images on mobile devices. Using the code below, but for some reason, the height remains at 13em on smartphones, despite setting it differently for other devices. Any ideas why this might be happening? @media only sc ...

Tips for getting validation to function properly on Bootstrap v4 using Bootstrap validator

Recently, I made the switch from Bootstrap v3 to v4, and although the JavaScript part of Bootstrap Validator is still functioning properly, the styling seems to have disappeared. The bootstrap validator that I utilized can be found here. This is how it c ...

Is there a way in CSS/3 to dynamically adjust the height based on the width?

Is there a way in CSS/3 to maintain the shape ratio of a div while keeping it responsive? Let's say the container is 100px wide. For example: width: 100%; height: 100%-of-width; Result: The div is 100px wide and 100px high. Another example: ...