Aligning multiple spans vertically within a div of varying height (ui-select-multiple)

I am currently using AngularJS ui-select's Multiselect feature.

If you want to see how my multiselect looks, check it out here: http://plnkr.co/edit/zJRUW8STsGlrJ38iVwhI?p=preview

When arranging spans in multiple lines, achieving nice vertical alignment can be a bit tricky.

I was able to achieve it for one line like this:

https://i.stack.imgur.com/2TAjW.jpg
(source: cs630525.vk.me)

However, I encountered issues when trying to align multiple lines nicely:

https://i.stack.imgur.com/wOCXg.jpg
(source: cs630525.vk.me)

https://i.stack.imgur.com/jQfIk.jpg
(source: cs630525.vk.me)

The goal is to have equal paddings with the same colors for "nice vertical alignment."

https://i.stack.imgur.com/dkZko.jpg
(source: cs630525.vk.me)

Here is the HTML snippet:

  <ui-select multiple class="ui-select-container ui-select-multiple ui-select-bootstrap form-control dropdown" 
             ng-model="multipleDemo.colors" ng-disabled="disabled">
      <ui-select-match class="ui-select-match" placeholder="Select colors...">{{$item}}</ui-select-match>
      <ui-select-choices repeat="color in availableColors | filter:$select.search">
        {{color}}
      </ui-select-choices>
  </ui-select>

Here is the CSS snippet:

.ui-select-multiple.ui-select-bootstrap {
  padding: 0 3px;
  min-height: 34px;
  height: auto;
  width: 300px;
}

.ui-select-match {
  display: inline;
  vertical-align: baseline;
}

.ui-select-multiple.ui-select-bootstrap input.ui-select-search {
  min-height: 32px;
  margin: 0;
}

.ui-select-multiple.ui-select-bootstrap > div {
  min-height: 32px;
}

.form-control {
  display: block;
  width: 100%;
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857143;
  color: #555;
  background-color: #fff;
  background-image: none;
  border: 1px solid #ccc;
  border-radius: 4px;
}

How can I achieve consistent vertical alignment with equal paddings?

Answer №1

Please include the following code snippet in your CSS file:

.ui-select-multiple.ui-select-bootstrap .ui-select-match-item { 
   display:block; 
} 

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

Use Javascript or Jquery to dynamically change the background color of cells in HTML tables based on their numerical

I am working with a collection of HTML tables that contain numbers presented in a specific style: <table border="1"> <tr> <th>Day</th> <th>Time</th> <th>A</th> <th>B</th> &l ...

How to switch between classes for elements and return to the original one when none of the elements is chosen

Hello there, I need some assistance. Here's the scenario: I am working with a grid of six items. My goal is to have the first item in the grid become active by default. When the user hovers over any of the remaining five items, I want the active clas ...

Contrasting WebSQL and SQLite in terms of their utility in mobile applications and web browsers

Could you confirm if WebSQL and SQLite are the same? Are both WebSQL and SQLite available in PhoneGap? Will the JavaScript code used for WebSQL in a web browser be the same for a mobile app, or will we need different code? What advantages does WebSQL ha ...

Persist user input even after reloading the page

In order to enhance the user experience, I would like to implement a feature where the data entered by the user is preserved even if they refresh, reload, or close the page. This includes retaining the selections made in the select elements. Additionally, ...

What causes scope to be undefined in Angular?

Using ionic to develop a hybrid app has been a smooth experience, especially with android! This is my login HTML: <body ng-app="starter"> <head> <script src="phonegap.js"></script> </head> <ion-header-ba ...

What could be the reason for my CSS selector with :target not functioning properly?

I tried to implement the instructions I found online for using :target, but it's not working as expected. My goal is to change the background color and font color of #div1 when the first link is clicked, and to change the border of #div2 when the seco ...

Tips for duplicating specific div elements

Is there a way to create copies of selected divs within the same panel using a Javascript report designer? I attempted to achieve this by using the following code snippet: function DesignerClone() { $(".ui-selected").each(function () { va ...

I'm curious about why I'm receiving the error "Unable to bind to 'ngFor' since it is not recognized as a property of 'li'. Can someone please explain why this is happening?

The issue is related to the *ngFor directive for nonvegfoodlist app.component.ts import { Component } from '@angular/core'; export class Menu { id : number; name :string; } const veg : Menu[] = [ { id:1 , name:'Rice'}, { id: ...

I'm confused as to why only one of my HTML pages is accepting my CSS styling - not sure what's going on

I am facing an issue where the CSS styles are only being applied to one of the HTML pages I created. Despite checking my code multiple times, everything seems to be correct. All the necessary files are saved on my laptop in the same folder for the website. ...

Does the downloading of images get affected when the CSS file has the disabled attribute?

Is it possible to delay the download of images on a website by setting the stylesheet to 'disabled'? For example: <link id="imagesCSS" rel="stylesheet" type="text/css" href="images.css" disabled> My idea is to enable the link later to tri ...

What could be causing my CSS navigation toggle button to malfunction?

My attempt at creating a toggle button for tablets and phones seems to be failing. Despite the javascript class being triggered when I click the toggle button, it is not functioning as expected... https://i.stack.imgur.com/j5BN8.png https://i.stack.imgur. ...

A step-by-step guide to creating a CSS menu using pure HTML markup

I have been working on the CSS for a menu using some HTML code, but I am stuck and uncertain about my next steps. Here is the CSS I have added so far: #menu-my-integra, ul.sub-menu { list-style: none; padding: 0; margin: 0; } #menu-my-integra li ...

Ensure that any modifications made to an Angular service are reflected across all components that rely on that service

I am currently in the process of replicating a platform known as Kualitee.com, which serves as a test-management tool utilized by QA Engineers. Within Kualitee, users can access multiple projects, each containing various test cases and team members. The ab ...

Scrolling to an id within dynamically loaded content using jQuery after an ajax request

After loading content via ajax, I am unable to scroll to the item, as the page remains at the top. Strangely, when I refresh the page dynamically with content caching enabled, the page scrolls to the desired target. var startPageLoader = function( pid, si ...

Adjust image size based on window dimensions changes

Let me demonstrate the issue I'm facing with this demo. This demo shows a simple list of images that scrolls across the page. When you click on an image, a larger version appears above it in a lightbox style. I want the height of this larger image ...

Try incorporating a variety of colors to enhance the appearance of your paper-menu in Polymer 1

I'm currently working on creating a customized menu using Polymer 1.0. This is how my menu structure looks like: <paper-menu> <template is="dom-repeat" items="{{menu}}" as="item"> <paper-item> <div>{{item.title}}</div& ...

CSS: ways to set a maximum height for a datalist container

Hello, I have a datalist with over 100 options and I would like to set a maximum height for it to ensure the design looks tidy. Can anyone please help me out with this? Thank you! <input type="text" list="suggestions" class="f ...

Guide on integrating jQuery for AJAX responses to gracefully transition into view within an MVC3 View

Is there a way to create a smooth fade in effect for a <p> element on my website? Currently, I am using Ajax to retrieve the server time and display it. However, the elements appear abruptly and I would like to make the transition more gradual by ad ...

Yet again faced with an annoying gap between table rows and cells, for the 532nd instance

Once again, tables have defeated me. I am struggling with a simple table: <table style="width: 200px; margin: 20px auto; border-collapse: collapse; border-spacing: 0; border: none;"> <tr style="margin: 0; padding: 0; border: none; border-colla ...

Viewport height-responsive image not functioning as expected in Firefox browser

Is there a way to set an image to the 100% height of the browser window, with a small padding at the bottom, and have it centered on the page? I created an example in codepen that works well in Chrome and Safari, but not in Firefox. In Firefox, the image ...