Trouble setting table row's background color with CSS

1,747 views
Skip to first unread message

D. Williams

unread,
Jun 1, 2010, 1:52:56 PM6/1/10
to dompdf
This is the last of my hurdles before I have a working report system
=D

My report engine generates its tables with each row alternating
classes between row1 and row2. That way, I can easily set the rows
apart visually using CSS to apply the row color.

Now, I know that this functions correctly since I allow the user to
either send the report to their browser or to a PDF. No matter what
they do, the exact same HTML and CSS is generated. If shown in the
browser, the colors work fine. With the PDF, however, they do not. I
have the following line in the header of the HTML sent to DOMPDF:

<link rel="stylesheet" href="report.css" type="text/css" />

report.css is very simple and contains the following rules:

.row2 { background-color:#EEEEEE; }
th { border-bottom-style: solid; }
.totalsbar { border-bottom-style: solid; }

All of them work except the .row2 class rule. For testing purposes, I
tried changing .row2 to font-size 200%; just to make sure it was
matching and, sure enough, the text was enlarged.

How can I get my background color to change? I'm running DOMPDF
version 0.5.1.

Fabien Ménager

unread,
Jun 1, 2010, 4:28:15 PM6/1/10
to dompdf
Hello, could you try the version 0.6 beta ? If it still doesn't work,
you should try with this CSS :

.row2 td { background-color:#EEEEEE; }

BrianS

unread,
Jun 1, 2010, 11:17:32 PM6/1/10
to dompdf
I can confirm it still doesn't work with the beta (or the latest SVN
trunk). There appears to be a cascading problem with the background-
color property. But the background property seems to work just fine,
so you could also try the following:

.row2 { background: #EEEEEE; }

See the following for an example:

HTML: http://eclecticgeek.com/dompdf/debug_tests/dcaa0feaea754243.htm
PDF: http://eclecticgeek.com/dompdf/index.php?input_file=dcaa0feaea754243.htm&dompdf_ver=trunk&load_method=1&output_method=stream

-b

D. Williams

unread,
Jun 2, 2010, 10:00:22 AM6/2/10
to dompdf
Just using the background property does indeed make the color appear
as expected, thanks!

@Fabien - I didn't try the beta version but I tried adding a tr
selector to my rule but nothing changed

On Jun 1, 10:17 pm, BrianS <eclecticg...@gmail.com> wrote:
> I can confirm it still doesn't work with the beta (or the latest SVN
> trunk). There appears to be a cascading problem with the background-
> color property. But the background property seems to work just fine,
> so you could also try the following:
>
>   .row2 { background: #EEEEEE; }
>
> See the following for an example:
>
> HTML:http://eclecticgeek.com/dompdf/debug_tests/dcaa0feaea754243.htm
> PDF:http://eclecticgeek.com/dompdf/index.php?input_file=dcaa0feaea754243....
Reply all
Reply to author
Forward
Message has been deleted
0 new messages