What is CSS?
PLONE CONFERENCE 2011
* Cascading Style Sheets
* Controls colors, fonts, sizes, positioning, etc
What is CSS?
PLONE CONFERENCE 2011
The cascade determines the order in which the
CSS is prioritized.
Factors include:
* order of importation
(Plone CSS Registry)
* specificity of selectors
* !important
flickr/Cayusa
How to insert CSS
PLONE CONFERENCE 2011
External:
<link rel=”stylesheet” type=”text/css”
href=”public.css”>
Embedded:
<style type=”text/css”>
body { background-color: #f1f1f1; }
</style>
Inline:
<p style=”color: #333333;”>
Selector Specificity
PLONE CONFERENCE 2011
h1.documentFirstHeading { ... }
- an h1 with the class documentFirstHeading
.section-news #content { ... }
- styles for #content when inside .section-news
#region-content.documentContent { ... }
- an element with both the id region-content
and class documentContent
A Matter of !Importance
PLONE CONFERENCE 2011
h1 { color: #ff0000 !important; }
will override
.section-news #content h1 { color: #333333; }
even though the second is more specific.
Use !important sparingly!
Pseudo Selectors
PLONE CONFERENCE 2011
Most popularly used on anchors for applying
styles to their different states:
a:hover
a:active
a:visited
flickr/Plbmak
Block vs Inline
PLONE CONFERENCE 2011
li { display: block; }
Block level elements start on a
new line and fill the space of
their parent. (p, div)
Inline items appear in line with
the text. (span, em, img) flickr/lobo235
Display Options
PLONE CONFERENCE 2011
one
block two
three
four
inline one two three four
one
two < for bullet display on li
list-item three
four
none < similar to visibility: hidden,
but doesn’t leave a space
Display Options
PLONE CONFERENCE 2011
* Block items should not be put inside inline items
* Inline items can be made “block” for applying
width and height
* Also, there is inline-block!
Box Model
PLONE CONFERENCE 2011
flickr/cmdshiftdesign
Floats & Clears
PLONE CONFERENCE 2011
img { float: right; }
Floats will push an element to one side and allow
content to wrap around it
Floats & Clears
PLONE CONFERENCE 2011
1. Containers don’t expand
for the floating content
2. You may not want the
next element to wrap
around the float.
You can use Plone’s .visualClear on a div, or :after
Floats & Clears
PLONE CONFERENCE 2011
With a clear: both; at the
end of the purple div.
overflow: auto; would also
do this
With a clear before the
next paragraph
Positioning
PLONE CONFERENCE 2011
* space is removed
* positioned within parent that
has position: relative;
(body, if none)
* position: fixed is similar, but
will stay in place when scrolling
* z-index can be applied for determining
top to bottom order
Multiple Backgrounds
PLONE CONFERENCE 2011
.box {
background:
url(‘base.jpg’) repeat-x bottom left,
url(‘top.jpg’) repeat-x top left,
url(‘middle.jpg’) repeat-y top center;
}
* separate with comma
* order from front to back
* only last can have a background color
Rounded Corners
PLONE CONFERENCE 2011
.box {
border: 1px solid #ffffff;
border-radius: 0 30px 30px 30px;
}
* clockwise from top left
* can make circles
Browser Stats
PLONE CONFERENCE 2011
X CSS3
~ CSS3
X CSS3
X CSS3
Firebug
PLONE CONFERENCE 2011
* Firefox web development tool
* Live Source Code (with JS applied)
* Styles
* Code is editable on the fly for
display in the browser. Changes
are not saved, and will reset on
refresh.
Firebug Inspector
PLONE CONFERENCE 2011
* Right click an element, select “Inspect Element”
* Or with Firebug open, click the Inspector, then
click an element
This will highlight the element in the HTML tab
Firebug Inspector
PLONE CONFERENCE 2011
With an element highlighted in the HTML tab,
you can see the styles applied to it.
Firebug Styles
PLONE CONFERENCE 2011
The style tab shows how the styles are cascading
in descending order
Firebug Styles
PLONE CONFERENCE 2011
In the Style tab, styles can
be adjusted, and new
properties can be added.
The browser will display
the changes. Values can
be typed or adjusted with
arrow keys
Firebug Styles
PLONE CONFERENCE 2011
The Layout tab shows box model styles. Values
can be adjusted here, and will only apply to the
selected element.
Firebug Styles
PLONE CONFERENCE 2011
To disable a style, hover over it, then click the
icon that will appear to the left
Add-ons For Your Add-on
PLONE CONFERENCE 2011
Firebug Extensions:
* Pixel Perfect
* FireDiff
Other Firefox Extensions:
* MeasureIt
* ColorZilla
* Web Developer Toolkit