css3 - property nth-child seems not working in JSP CSS -
i created program fill in table data of table called usuarios property nth-child seems not working rows have same color, greenyellow; . using netbeans , glassfish
<%-- document : basededatos created on : 14/06/2015, 01:23:57 author : fernando --%> <%@page import="java.sql.*"%> <%@page contenttype="text/html" pageencoding="utf-8"%> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>jsp page</title> <style type="text/css"> .tftable{ width:100%; border-collapse:collapse; } .tftable td{ padding:7px; border:#4e95f4 1px solid; } /* provide minimal visual accomodation ie8 , below */ .tftable tr{ background: red; } /* define background color odd background rows */ .tftable tr:nth-child(odd){ background: yellow; } /* define background color background rows */ .tftable tr:nth-child(even){ background: greenyellow; } </style> </head> <body> <% connection conn = null; resultset result = null; statement stmt = null; resultsetmetadata rsmd = null; try { class.forname("com.mysql.jdbc.driver"); out.println("driver registrado"); conn = drivermanager.getconnection("jdbc:mysql://127.0.0.1:3306/administracion", "root", "strlen12"); out.println("conexion exitosa"); stmt = conn.createstatement(); result = stmt.executequery("select * usuarios"); %> <table border="1" class="tftable"> <caption>lista de usuarios</caption> <tr style="background-color: grey"> <td>nombre</td> <td>codigo</td> </tr> <% while (result.next()) { %> <tr> <td> <% out.print(result.getstring(1)); %> </td> <td> <% out.print(result.getstring(2)); %> </td> <tr> <% } %> </table> <% } catch (exception e) { out.print(e); } %> </body> </html>
the problem you're not closing tr
tags
change this:
<tr> <td> <% out.print(result.getstring(1)); %> </td> <td> <% out.print(result.getstring(2)); %> </td> <tr>
to:
<tr> <td> <% out.print(result.getstring(1)); %> </td> <td> <% out.print(result.getstring(2)); %> </td> </tr>
Comments
Post a Comment