Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I display data in result div that contains a href links
I want to use :nth-of-type on the links it works fine

C#
#result a:nth-of-type(even) {
      background-color:#edeaea;
      
 
   }

But right now it display the background-color only as the size of the text
But i want to display the backgroundcolor as full with of the result table
so i have tried with using
CSS
display:block;

It then displays the color as the table div width but it also create white spaces between
So for ex
Data1 = white
Data1 = #edeaea
Here is not data it display white color even if its no data here
Then Data3 = white
Then Data4 = #edeaea
And then again here its white here is no data
Posted
Comments
Kornfeld Eliyahu Peter 14-Jan-15 3:18am    
Can you show the HTML this CSS applies to?
Sinisa Hajnal 14-Jan-15 3:39am    
You can use nth-child(2n) to get all even elements.
Odd elements will have default background color as you haven't specified it for them.
Instead of having display: block; try setting setting line-height to wanted height (and maybe fixed (or percentage) width and height). Maybe play with paddings to fill out left and right parts.

1 solution

I think you are targeting the wrong element.
Since you're talking about a table, you should target the "tr" elements.
This way, it doesn't matter what the table content is.
There will be no white space.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900