0

I have a web-based utility for chess tournament manual pairings. I need to format jquery ui autocomplete to make the white players select menu items left justified and the black players select menu items right justified. Here is the link: http://communitychessclub.com/test.php

I have seen many confusing and probably contradictory CSS styling methods. For example:

ul.ui-autocomplete.ui-menu {background:pink; font-size:1.5rem; text-align:center; letter-spacing:2px;}  

.ui-widget-content.ui-menu .ui-menu-item {color: red; font-weight: bold;}
.ui-widget-content.ui-menu .ui-menu-item {color: tan; font-weight: bold;}

the HTML:

<div class = "ui-widget white"><input type = "text" class = "automplete-2"></div>
<div class = "ui-widget black"><input type = "text" class = "automplete-2"></div><br />

How can I have the white player's autocomplete listing left-justified and the black player's autocomplete listing right-justified.

3
  • I need text-align:left for black players and text-align:right for the white players Commented Aug 7, 2017 at 3:53
  • Looks ok on your test page, unless you want to swap white and black justification, then just switch text-alight: left; with text-align: right; Commented Aug 7, 2017 at 4:17
  • Not at all... I am using jquery autocomplete... and I want that list to be alternately right / left justified. Commented Aug 7, 2017 at 4:43

1 Answer 1

1

Try the even / odd argument of nth-of-type CSS selector:

.ui-menu:nth-of-type(even) li div{  /* black */
  text-align: left !important;
}
.ui-menu:nth-of-type(odd) li div{  /* white */
  text-align: right !important;
}
Sign up to request clarification or add additional context in comments.

1 Comment

I edited... Since there is some div in between... There were all even using nth-child(even/odd)... So I found nth-of-type is working. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.