CSSAMP is a CSS only framework for AMP HTML that styles frequently used HTML tags without the need for classes. It also provides a few utilities such as a responsive grid and CSS-only tooltips.
CSSAMP can be used stand-alone or as a foundation to build upon. This site you're viewing now uses CSSAMP and is all you need to get started.
Compatible with all modern browsers and IE9+.
No download necessary. This page uses the latest CSSAMP version and is the template.
Sometimes you want to quickly set up a simple site or application. You don't want it to look like a Word™ doc but you also don't want/need a massive framework such as Bootstrap or Foundation or Materialize.
So in a similar vein as Pure and Skeleton, CSSAMP aims to provide a minimal CSS framework that requires minimal setup.
CSSAMP takes this minimal approach one step further by making it completely classless. Not only that, but the default styles are only applied to elements without classes. Why only bare tags? For custom components and modules, you may not want the standard stylings to apply, so by giving them a class you're removing all CSSAMP styling. If you want to add a class and want the CSSAMP styling applied, just add the data-xx
attribute to that element.
CSSAMP effectively changes the default browser styles. Any commonly used tags such as input
or button
are styled only if they don't have any classes.
What if you want to add a class to a tag but still want to retain the CSSAMP style? Just add the attribute data-xx
to the tag and the CSSAMP styles will be applied.
<!-- want to style a button? -->
<button>Button</button>
<!-- adding a class will remove the CSSAMP styling and use the default browser style -->
<button class="your-btn-class">Button</button>
<!-- adding the attribute data-xx to a tag with a class will apply the CSSAMP styling -->
<button data-xx class="your-btn-class">Button</button>
mark
elementdata-
now to be AMP-compatiblea
anchor tag added vertical-align:top
to maintain consistent placementdata-xx
default class has now been made an attributedata-tt
it's now just data-tt
data-att
attributeThis site that you're viewing right now is built on section
elements. The sections are horizontally centered, have a max-width
equal to 90rem, and will shrink with smaller screens. Useful for containing content quickly.
Note: Because of CSS specificity, overwriting the default style with a class will require specifying that the class applies to a section
element. Eg: Your CSS property should look like section.custom-section
rather than just .custom-section
.
<!-- use sections to quickly and easily contian content -->
<section>
Your code here.
</section>
Font sizes in CSSAMP are based in rem
s. You can set the initial font size in the html
element to change the scale. The default is 10px
so that 1rem is 10px and 2rem is 20px etc.
The font family defaults are just the standard browser defaults, so data-serif
, data-sans-serif
and data-monospace
fonts are chosen by the browser. You can change this in the CSS font variablea.
The main thing CSSAMP does to headings is to standardise the margins and paddings. h1
through to h6
are taken care of.
h1
Heading level 1h2
Heading level 2h3
Heading level 3h4
Heading level 4h5
Heading level 5h6
Heading level 6Tooltips are handy and CSSAMP provides you with classless, no javascript tooltips. Tooltips can be applied to most tags, as long as they accept the ::before
and ::after
pseudo elements. Just use data-tt="Your tooltip here"
in the tag.
Hover over this for a tooltip on a b
tag. Hover over this
, or this or even this to see tooltips in action.
Note: These tooltips aren't clever so they will spill offscreen. You'll need some Javascript if you want dynamic positioning.
<!-- inline element -->
<b data-tt="Tooltip">Tooltip</b>
<!-- buttons -->
<button data-primary data-tt="Primary button with a tooltip">Primary button</button>
<button data-tt="Normal button with a tooltip">Normal button</button>
If you want to tell your user why a button is disabled then you can use the data-dtt
attribute to show a tooltip when a button is disabled. This is handy for things such as invalid or incomplete forms.
You can use both data-tt
and data-dtt
on the same element and the button disabled
state will determine the tooltip shown.
Enter some text to enable the disabled button.
<!-- disabled buttons -->
<!-- note that you can have tooltips for enabled and disabled states -->
<button disabled="true" data-tt="Not disabled" data-dtt="Disabled">Disabled button</button>
You can easily set a tooltip for an anchor link that shows the href
on hover just by adding the data-att
attribute.
<!-- anchor link tooltips with the data-att attribute -->
<a data-att href="https://cssamp.com">CSSAMP</a>
Nothing special here, replacing the often ugly browser defaults with some CSSAMP style. Just note that you need to place the label
tag directly after the radio
and checkbox
inputs. Text inputs and select boxes are default to 100% width as you'll most likely use them in a grid.
<label>Username</label>
<input type="text" placeholder="username">
<label>Password</label>
<input type="password" placeholder="password">
<label>Comment</label>
<textarea placeholder="comment"></textarea>
<!-- select and option -->
<select>
<option disabled selected>Select an option</option>
<option>Option One</option>
</select>
<!-- checkbox -->
<input type="checkbox" id="checkbox-1"> <label for="checkbox-1">Checkbox 1</label>
<!-- radio -->
<input type="radio" name="radio" id="radio-1"> <label for="radio-1">Radio 1</label><br><input type="radio" name="radio" id="radio-2"> <label for="radio-2">Radio 2</label>
The code
tag functionality has been kept basic as you'll most likely be using something like PrismJS for syntax highlighting and code escaping.
Here is some inline
code.
if ( to_be || !to_be ) {
that = theQuestion;
}
<!-- inline code -->
<code>code</code>
<!-- pre code -->
<pre><code>Code line 1
Code line 2
Code line 3</code></pre>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris.
- Lorem Ipsum
<blockquote>
<p>Quote goes here.</p>
<p data-txt="r">
<i>- Said Someone</i>
</p>
</blockquote>
As long as the ul
or ol
tag is classless or has the data-xx
attribute the styles should apply to the child li
elements too.
The tables are just your standard table
element with thead
, tbody
, tr
, th
and td
elements within. As long as the table
tag is classless or with the data-xx
attribute, the styles should apply to the child elements.
When the user hovers over the head row, the relevant column will be highlighted. Any other row and the entire row will be highlighted.
Title one | Title two | Title three | Title four |
---|---|---|---|
Row 1 col 1 | Row 1 col 2 | Row 1 col 3 | Row 1 col 4 |
Row 2 col 1 | Row 2 col 2 | Row 2 col 3 | Row 2 col 4 |
Row 3 col 1 | Row 3 col 2 | Row 3 col 3 | Row 3 col 4 |
Row 4 col 1 | Row 4 col 2 | Row 4 col 3 | Row 4 col 4 |
Getting a classless grid system in AMP requires using the standards compliant and totally working span
element.
The CSSAMP grid is simple and succinct. It's also fully responsive so that's nice. Just use the span
element and throw some div
s with data-col
attributed children in there and you're good. No need for row
as the data-col
s will wrap around.
Since there are no rows, column widths are expressed in fractions which should make identifying rows easier. Eg: 1/3
and 2/3
make a row.
Note that each column in this grid will be 100% width on a mobile device.
<!-- no need for rows, span will act as both row and container -->
<span>
<div data-col="1/3"></div>
<div data-col="2/3"></div>
<!-- new row -->
<div data-col="1/2"></div>
<div data-col="1/2"></div>
</span>
The grid columns will automatically expand to 100% width when the viewport reaches the @mobile
width. To prevent this, add the data-fx
attribute to the column.
<!-- adding data-fx to the data-col will retain width on mobile -->
<span>
<div data-fx data-col="5/12"></div>
<div data-fx data-col="7/12"></div>
</span>
You can place a span
inside of data-col
to nest grids. You can do this as many times as you like.
<!-- you can nest a span inside a col -->
<span>
<div data-col="1/2"></div>
<div data-col="1/2">
<!-- nested grid -->
<span>
<div data-col="1/1"></div>
<div data-col="1/2"></div>
<div data-col="1/2"></div>
</span>
</div>
</span>
The examples you are looking at now are all col
s within a span
separated by hr
s.
<!-- you can use a hr to separate cols -->
<span>
<div data-col="1/2"></div>
<div data-col="1/2"></div>
<hr>
<div data-col="1/2"></div>
<div data-col="1/2"></div>
</span>
Cards use the also totally compliant figure
element and works fine in IE9+. These cards are meant to be used within a grid.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.
<!-- figure element -->
<figure>
<p>Your content</p>
</figure>
<!-- card within a grid -->
<span>
<div data-col="1/2">
<figure>
<h5>Card title</h5>
<hr>
<p>Your content here</p>
</figure>
</div>
<div data-col="1/2">
<figure>
<h5>Card title</h5>
<hr>
<p>Your content here</p>
</figure>
</div>
</span>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
<!-- image at the top -->
<figure>
<amp-img data-xx src="sign.jpg" width="640" height="427" layout="responsive">
</amp-img>
<h5>Title</h5>
<p>Content goes here</p>
</figure>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
<!-- image in the middle -->
<figure>
<h5>Title</h5>
<amp-img data-xx src="sign.jpg" width="640" height="427" layout="responsive">
</amp-img>
<p>Content goes here</p>
</figure>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
<!-- image at the bottom -->
<figure>
<h5>Title</h5>
<p>Content goes here</p>
<amp-img data-xx src="sign.jpg" width="640" height="427" layout="responsive">
</amp-img>
</figure>
CSSAMP has a few utility attributes to make laying out a site a little faster. Sometimes you don't need to give an element a unique class to make it's text align right. Use these attributes to apply quick styles such as paddings or margins.
Attribute | Values | Effect |
---|---|---|
data-full |
null | Width 100% |
data-hide |
null | Display none |
data-fs |
xs s m l xl |
Sets font sizes from 1.1rem to 2.4rem |
data-mt |
0 2 4 8 |
Sets margin-top from 0 to 8rem |
data-mb |
0 2 4 8 |
Sets margin-bottom from 0 to 8rem |
data-pt |
0 2 4 8 |
Sets padding-top from 0 to 8rem |
data-pb |
0 2 4 8 |
Sets padding-bottom from 0 to 8rem |
data-pa |
0 2 |
Either removes all padding or sets padding for all sides to 2rem |
data-txt |
l c r j |
Sets text alignment to left, center, right or justify |
<!-- margin top 2rem + margin bottom 4rem -->
<div data-mt="2" data-mb="4"></div>
<!-- padding all 2rem -->
<p data-pa="2"></p>
<!-- text align right + font size small -->
<p data-txt="r" fs="s"></p>