1

I am starting to understand how to edit the CSS of individual views on my site. I use the Views module (release 2). I know Views 3 makes life easier in these things but for now I have to use Views 2.

I have a comment block on my site. I wondering if it is best/easier to add some kind of div class to a fields TPL file or wether I could just change it in my CSS file. I seem to have tried both in my time with various success. I really struggle to find out what part of the div class I need to change in a view when viewing it with Firebug.

This for instance:

view view-comments-recent view-id-comments_recent view-display-id-block view-dom-id-5

Would I make the css something like

.view-comments-recent view-id-comments_recent view-display-id-block view-dom-id-5 body { font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:16px; }

to change the text in the comment field?

I feel it might be better to create a views-view-field--comments-recent--block--comment.tpl.php file and then do something like this:

 <div class="mynewclass"><the print output bit> </div>

And then add this:

.mynewclass body {
font-family:Arial, Helvetica, sans-serif;
  font-size:12px;
  line-height:16px;
}

Or maye that would be like so:

.mynewclass p {
font-family:Arial, Helvetica, sans-serif;
  font-size:12px;
  line-height:16px;
}

Could anyone help me with what I am trying to do? I feel like I almost have it.

Which way would be best do you think?

2

You should be able to set a custom css class for each field, but otherwise your technique of drilling down using css classes is fairly common practice.

  • Thanks boombatower. Truth be told i was just in a bit of a panic when i posted. things are starting to make more sense to me. I think i just need to learn more about css. – Reg Gordon Feb 21 '12 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.