-1

I want to put background color just in the odd ones for "card h-90 text-left" how can i be able to achieve it? I know how to put it in all of them but i just need it for the odd ones.

<div class="row">
        <%
            int i;
            int size = empDetailsMap.size();
            Employee employee = new Employee();
            for (Map.Entry<String, Employee> entry : empDetailsMap.entrySet()) {

                String key = entry.getKey();
                employee = entry.getValue();
        %>

        <div class="col-lg-4 mb-3">
            <div class="card h-90 text-left">
                <div class="card-body custom-cards">
                    <h5 class="card-text" id="huddle">
                        <div style="text-align: left">
                            <%
                                out.println(employee.getFirstName() + " " + employee.getLastName());
                            %>

                        </div>
                    </h5>
                    <h6 class="card-subtitle mb-2 text-muted">
                        <div style="text-align: left">
                            <%
                                for (i = 0; i < employee.getTaskAssignment().getMinorTaskName().size(); i++) {
                                        out.println(employee.getTaskAssignment().getMinorTaskName().get(i) + " - "
                                                + employee.getTaskAssignment().getAssignedDetails().get(i) + " - "
                                                + employee.getTaskAssignment().getEstTime().get(i) + "\n");
                            %>
                            <br>
                            <%
                                }
                            %>

                        </div>
                    </h6>
                </div>
            </div>
        </div>
        <%
            }
        %>
    </div>
Edwin Bossman
  • 91
  • 2
  • 10
  • 3
    Possible duplicate of [:nth-child(even/odd) selector with class](https://stackoverflow.com/questions/17458582/nth-childeven-odd-selector-with-class) – jmargolisvt Oct 31 '17 at 18:13
  • https://stackoverflow.com/questions/6211613/testing-whether-a-value-is-odd-or-even – epascarello Oct 31 '17 at 18:14

1 Answers1

1

To achieve the effect you are after:

.col-lg-4.mb-3:nth-child(odd) .card {
    background-color: #ebebeb;
}

Change the background-color to whichever colour you wish to use.

Here is more information on nth-child: https://css-tricks.com/almanac/selectors/n/nth-child/

Josh Murray
  • 619
  • 5
  • 18