1 |
85ad3d82
|
Assos Assos
|
Views uses a wide array of CSS classes on all of its content to ensure that you can easily and accurately select exactly the content you need in order to manipulate it with CSS.
|
2 |
|
|
|
3 |
|
|
It is possible to enter a custom css class under <a href="topic:views/style">Style</a> settings. The <strong>CSS class</strong> names will be added to the view. This enables you to use specific CSS code for each view. You may define multiples classes separated by spaces.
|
4 |
|
|
|
5 |
|
|
Typically, every view is wrapped in a div with the name of the view as part of its class (for all these examples, we will assume the name of the view is <strong>myview</strong>), as well as the generic class 'view':
|
6 |
|
|
|
7 |
|
|
<pre>
|
8 |
|
|
<div class="view view-myview">
|
9 |
|
|
...
|
10 |
|
|
</div>
|
11 |
|
|
</pre>
|
12 |
|
|
|
13 |
|
|
In your CSS, you can modify all views:
|
14 |
|
|
|
15 |
|
|
<pre>
|
16 |
|
|
div.view {
|
17 |
|
|
border: 1px solid black;
|
18 |
|
|
}
|
19 |
|
|
</pre>
|
20 |
|
|
|
21 |
|
|
Or just your view:
|
22 |
|
|
|
23 |
|
|
<pre>
|
24 |
|
|
div.view-myview {
|
25 |
|
|
background: yellow;
|
26 |
|
|
}
|
27 |
|
|
</pre>
|
28 |
|
|
|
29 |
|
|
By default, the general view template also provides the following classes to easily style other areas of the view:
|
30 |
|
|
<ul>
|
31 |
|
|
<li> .view-header </li>
|
32 |
|
|
<li> .view-filters </li>
|
33 |
|
|
<li> .view-content </li>
|
34 |
|
|
<li> .view-empty (if an "empty" text is used when the view has no results) </li>
|
35 |
|
|
<li> .view-footer </li>
|
36 |
|
|
<li> .feed-icon </li>
|
37 |
|
|
<li> .attachment-before (if using an "attachment" display)</li>
|
38 |
|
|
<li> .attachment-after (if using an "attachment" display)</li>
|
39 |
|
|
</ul>
|
40 |
|
|
|
41 |
|
|
So for example:
|
42 |
|
|
<pre>
|
43 |
|
|
div.view-myview div.view-header {
|
44 |
|
|
/* make the header stand out */
|
45 |
|
|
font-size: 120%;
|
46 |
|
|
font-weight: bold;
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
div.view-myview div.view-footer {
|
50 |
|
|
/* Make the footer less important */
|
51 |
|
|
font-size: 80%;
|
52 |
|
|
font-style: italic;
|
53 |
|
|
color: #CCC;
|
54 |
|
|
}
|
55 |
|
|
</pre>
|
56 |
|
|
|
57 |
|
|
In the above example, we whimsically made the header bold and in a bigger font, and the footer smaller, italicized, and greyish.
|
58 |
|
|
|
59 |
|
|
<h3>Views with fields</h3>
|
60 |
|
|
If your view has fields, each field is uniquely tagged with its ID. A field's ID may be gleaned from the Theme: Information page. Note that due to CSS rules, any _ in the id will be converted to - automatically, so if you have a field whose id is 'edit_node' (this is the field used to provide an "edit" link to a node), it will be 'edit-node'. Additionally, to make sure that the view IDs don't conflict with other css classes in the system, they will be pretended with 'views-field-'; thus, the final CSS class for the field with the id 'edit_node' will be <strong>views-field-edit-node</strong>.
|
61 |
|
|
|
62 |
|
|
Exactly how this appears is going to depend upon the style you're using. For example, the 'unformatted' style uses <strong>div.views-field-edit-node</strong> and <strong>div.views-label-edit-node</strong> to access that particular field, but a table would use <strong>td.views-field-edit-node</strong> and <strong>th.views-field-edit-node</strong> to access the table header; or just <strong>.views-field-edit-node</strong> to affect both.
|
63 |
|
|
|
64 |
|
|
<pre>
|
65 |
|
|
.view-myview th {
|
66 |
|
|
color: red; /* make all headers red */
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
.view-myview .views-field-title {
|
70 |
|
|
font-weight: bold; /* Make the 'title' field bold */
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
.view-myview td.views-field-body {
|
74 |
|
|
font-size: 60%; /* Make the text in the body field small */
|
75 |
|
|
}
|
76 |
|
|
</pre> |