W3.CSS Pagination


W3.CSS Paginations

If you have a web site with lots of pages and you want to list them with direct access, you may want to consider adding some sort of pagination to each page.

This makes for a conservative way to create a simple page numbering system as a navigational element for documents.



Basic Pagination

To create a basic pagination, add the pagination class to an <ul> element:

Example

<ul class="pagination">
  <li><a href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>
</ul>
Try It Yourself »

Pagination Arrows

Use HTML entities or icons from an icon library to add pagination arrows. For more information regarding icons refer to the Icons Chapter.

Example

<ul class="pagination">
  <li><a href="#">&laquo;</a></li>
  <li><a href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>
  <li><a href="#">&raquo;</a></li>
</ul>
Try It Yourself »

Active State

Use one of the color classes to indicate which page the user is on:

Example

<ul class="pagination">
  <li><a href="#">&laquo;</a></li>
  <li><a class="green" href="#">1</a></li>
  <li><a href="#">2</a></li>
  <li><a href="#">3</a></li>
  <li><a href="#">4</a></li>
  <li><a href="#">5</a></li>
  <li><a href="#">&raquo;</a></li>
</ul>
Try It Yourself »

Pagination Sizing

Use tiny, small, large, xlarge, xxlarge or xxxlarge to size the pagination:

Example

<ul class="pagination xlarge">
Try It Yourself »

Bordered Pagination

Add the border class to create a pagination with borders:

Example

<ul class="pagination border">
Try It Yourself »

Rounded Borders

Add the round class next to border for rounded borders:

Example

<ul class="pagination border round">
Try It Yourself »

Centered Pagination

To center the pagination, wrap a <div> element with class="center" around <ul>:

Example

<div class="center">
  <ul class="pagination xlarge">
    ...
  </ul>
</div>
Try It Yourself »

 







W3.CSS Input


Input Form









Top Labels

Input Form

Example

<form class="w3-container">

<p>
<label>First Name</label>
<input class="w3-input" type="text">
</p>

<p>
<label>Last Namel</label>
<input class="w3-input" type="text">
</p>

</form>
Try It Yourself »

Bottom Labels

Input Form

Example

<form class="w3-container">

<p>
<input class="w3-input" type="text">
<label>First Name</label>
</p>

<p>
<input class="w3-input" type="text">
<label>Last Name</label>
</p>

</form>
Try It Yourself »

Green Labels

The w3-label class labels are green by default.

Input Form


Example

<form class="w3-container">

<p>
<label class="w3-label">First Name</label>
<input class="w3-input" type="text"></p>

<p>
<label class="w3-label">Last Name</label>
<input class="w3-input" type="text"></p>

</form>
Try It Yourself »

Input Cards

Input Form


Example

<div class="w3-card-4">

<div class="w3-container w3-green">
  <h2>Input Form</h2>
</div>

<form class="w3-container">

<p>
<label class="w3-label">First Name</label>
<input class="w3-input" type="text"></p>

<p>
<label class="w3-label">Last Name</label>
<input class="w3-input" type="text"></p>

</form>

</div>
Try It Yourself »

Validating Labels

Validating labels are red, and turns green when the input becomes valid.

To make labels validating, add a w3-validate class to your w3-label class.

Input Form


Example

<form class="w3-container">

<p>
<input class="w3-input" type="text" required>
<label class="w3-label w3-validate">First Name</label></p>

<p>
<input class="w3-input" type="text" required>
<label class="w3-label w3-validate">Last Name</label></p>

<p>
<input class="w3-input" type="email" required>
<label class="w3-label w3-validate">Email</label></p>

</form>
Try It Yourself »

Bordered Input

The w3-border class can be used on input.

Input Form


Example

<form class="w3-container">

<p>
<label>First Name</label>
<input class="w3-input w3-border" type="text"></p>

<p>
<label>Last Name</label>
<input class="w3-input w3-border" type="text"></p>

</form>
Try It Yourself »

Colored Labels

You can use both bold and color classes on labels:

Input Form

Register

Example

<form class="w3-container">

<h2 class="w3-text-blue">Input Form</h2>

<p>
<label class="w3-label w3-text-blue"><b>First Name</b></ label>
<input class="w3-input w3-border" type="text"></p>
 
<p>
<label class="w3-label w3-text-blue"><b>Last Name</b></ label>
<input class="w3-input w3-border" type="text"></p>
 
</form>
Try It Yourself »

Colors

Feel free to use your favorite styles and colors:

Input Form

Register

Example

<form class="w3-container">

<p>
<label class="w3-label w3-text-brown"><b>First Name</b></ label>
<input class="w3-input w3-border w3-sand" type="text"></p>

<p>
<label class="w3-label w3-text-brown"><b>Last Name</b></ label>
<input class="w3-input w3-border w3-sand" type="text"></p>

<p>
<button class="w3-btn w3-brown">Register</button></p>

</form>
Try It Yourself »

Checkboxes

Example

<p>
<input class="w3-check" type="checkbox" checked="checked">
<label class="w3-validate">Milk</label></p>

<p>
<input class="w3-check" type="checkbox">
<label class="w3-validate">Sugar</label></p>

<p>
<input class="w3-check" type="checkbox" disabled>
<label class="w3-validate">Lemon (Disabled)</label></p>
Try It Yourself »

Radio Buttons

Example

<p>
<input class="w3-radio" type="radio" name="gender" value="male" checked>
<label class="w3-validate">Male</label></p>

<p>
<input class="w3-radio" type="radio" name="gender" value="female">
<label class="w3-validate">Female</label></p>

<p>
<input class="w3-radio" type="radio" name="gender" value="" disabled>
<label class="w3-validate">Don't know (Disabled)</label></ p>
Try It Yourself »

Select Options

Example

<select class="w3-select" name="option">
  <option value="" disabled selected>Choose your option</ option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
</select>
Try It Yourself »

 







W3.CSS Animate


W3.CSS Animations

Slide and fade in elements with W3.CSS Animations:






Animation is Fun!


Slide in Elements

Slide in an element from the top, bottom, left or right of the screen with the animate-* classes:

Class Defines
animate-top Animates an element 300px from the top of the screen to 0px
animate-bottom Animates an element 300px from the bottom of the screen to 0px
animate-left Animates an element 300px from the left of the screen to 0px
animate-right Animates an element 300px from the right of the screen to 0px

Fade in Elements

Fade in an element with the animate-opacity class:

Example

<div class="animate-opacity">..</div>


 







W3.CSS Modal


W3.CSS Modal

A modal is a dialog box/popup window that is displayed on top of the current page like a shade with a transparent background. The use of the modal element allows for creative ways to bring up message elements.


How To Create A Modal

Example

<!-- Trigger/Open the Modal -->
<button onclick="document.getElementById('id01').style.display='block'"
class="btn">Open Modal</button>

<!-- The Modal -->
<div id="id01" class="modal">
  <div class="modal-content">
    <div class="container">
      <span onclick="document.getElementById('id01') .style.display='none'"
      class="closebtn">&times;</span>
      <p>Some text in the Modal..</p>
      <p>Some text in the Modal..</p>
    </div>
  </div>
</div>
Try It Yourself »

The "modal" Class

A modal is any HTML container (like a <div>) with class="modal".


The "modal-content" Class

All modal content should be placed in an HTML container with class="modal-content".

Modal content can be any HTML element (headings, paragraphs, images, etc.)


Open a Modal

Use any HTML element to open the modal. This is often a button or a link.

Add the onclick attribute and point to the id of the modal (id01 in our example), using the document.getElementById() method and specify a unique ID that matches the "trigger" button (id01).

Note NOTE: Do not use the same id numbers for more than one element on the same page, it will create a conflict and keep them from running!

Closing a Modal

To close a modal, add the closebtn class to an element together with an onclick attribute that points to the id of the modal (id01). Appearantly the use of the little (x) is fairly common, (even unlabled). As you can see by this example that there are some things that are pretty much taken for granted as being commonly understood.

Note &times; (×) is an HTML entity that is the preferred icon for close buttons, rather than the letter "x".

Modal Header & Footer

Inside the <div> with class="modal-content", use container classes to create different sections in the modal:

Example

<div id="id01" class="modal">
  <div class="modal-content">
    <header class="container teal">
      <span onclick="document.getElementById('id01').style.display='none'"
      class="closebtn">&times;</span>
      <h2>Modal Header</h2>
    </header>
    <div class="container">
      <p>Some text..</p>
      <p>Some text..</p>
    </div>
    <footer class="container teal">
      <p>Modal Footer</p>
    </footer>
  </div>
</div>
Try It Yourself »

Modal As a Card

To display the modal as a card, add the card-* class to the modal-content container:

Example

<div class="modal-content card-8">
Try It Yourself »

Animated Modals

Use any of the animate-top|bottom|right|left classes to slide in the modal from a specific direction:

Example

<div class="modal-content animate-top">
<div class="modal-content animate-bottom">
<div class="modal-content animate-left">
<div class="modal-content animate-right">
Try It Yourself »

Modal Image

Click on the image to display it in full size:

Car

Example

<div class="modal-content animate-top">
<div class="modal-content animate-bottom">
<div class="modal-content animate-left">
<div class="modal-content animate-right">
Try It Yourself »

Modal Image Gallery

Click on an image to display it in full size:

Example

<div class="row-padding">
  <div class="container third">
    <img src="images/manarola.png" style="width:100%" onclick= "onClick(this)">
  </div>
  <div class="container third">
    <img src="images/monterosso.png" style="width:100%" onclick="onClick(this)">
  </div>
  <div class="container third">
    <img src="images/vernazza.png" style="width:100%" onclick="onClick(this);">
  </div>
</div>

<div id="m01" class="modal" onclick="this.style.display='none'">
  <img class="modal-content" id="img01" style="width:100%">
</div>

<script>
function onClick(element) {
  document.getElementById("img01").src = element.src;
  document.getElementById("m01").style.display = "block";
}
</script>
Try It Yourself »

 







W3.CSS Tooltips


Tooltips display text (or other content) when you hover over an HTML element.


Inline Tooltip Text

Hover over the sentence below!

London 9 million is the capital city of England.

The tooltip class defines the HTML element to hover over (tooltip container).

The text class defines the tooltip text:

Note Because of how tightly packed the text and the coinciding tags will be in order to achieve this effect, it is advised that you check and double check the spacing between words and tags.

Example

<p class="tooltip">London
<span class="text">9 million</span>
is the capital city of England</p>
Try It Yourself »

Inline Tooltip Tag

Hover over the sentence below!

London9 million is the capital city of England.

The tooltip class defines the HTML element to hover over (tooltip container).

The text class defines the tooltip text:

Example

<p class="tooltip">London
<span class="text tag">9 million</span>
is the capital city of England</p>
Try It Yourself »

Large Tooltip

Hover over this picture to see the effect:

Car

Wikipedia defines a car as a wheeled, self-powered motor vehicle used for transportation. Some cars though are not meant to be just simple transportation. Pictured is BMW 5 Series sedan, an example of impeccable teutonic engineering.

The tooltip class defines the HTML element to hover over (tooltip container).

The text class defines the tooltip text:

Example (text before the picture)

<div class="tooltip">

<p class="text">A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars typically have four wheels.(Wikipedia)</p>

<img src="bmw5.jpg" alt="Car" style="width:100%">

</div>
Try It Yourself »

Example (text after the picture)

<div class="tooltip">

<img src="bmw5.jpg" alt="Car" style="width:100%">

<p class="text">A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars typically have four wheels.(Wikipedia)</p>

</div>
Try It Yourself »

Absolute Tooltip

If you want the tooltip to appear in an absolute position, position the tooltip text (text):

Example

<p class="tooltip">London is the capital city of England.
<span style="position:absolute;left:0;bottom:18px"
class="text tag">9million</span></p>
Try It Yourself »

Colored Tooltip

If you want a colored tooltip, use the color classes:

Example

<span class="text tag red">9 million</span>
Try It Yourself »

Rounded Tooltip

If you want a rounded tooltip, use the round classes:

Example

<span class="text tag round">9 million</span>
Try It Yourself »

Small Tooltip

If you want a small tooltip, use the small class:

Example

<span class="text tag small">9 million</span>
Try It Yourself »

Tiny Tooltip

If you want a tiny tooltip, use the tiny class:

Example

<span class="text tag tiny" >9 million</span>
Try It Yourself »

Large Tooltip

If you want a large tooltip, use the large classes:

Example

<span class="text tag xlarge">9 million</ span>
Try It Yourself »

 







W3.CSS Responsive Fluid Grid




Responsive Grid

W3.CSS supports a 12 column responsive fluid grid.

Resize the page to see the effect!

1
2
3
4
5
6
7
8
9
10
11
12

This part will occupy 12 columns on a small screen, 4 on a medium screen, and 3 on a large screen.

This part will occupy 12 columns on a small screen, 8 on a medium screen, and 9 on a large screen.

1
2
3
4
5
6
7
8
9
10
11
12

Example

<div class="row">
  <div class="col m4 l3">
    <p>
    I will occupy 12 columns on a small screen, 4 on a medium screen, and 3 on a large screen.
    </p>
  </div>
  <div class="col m8 l9">
    <p>
    I will occupy 12 columns on a small screen, 8 on a medium screen, and 9 on a large screen.
    </p>
  </div>
</div>
Try It Yourself »

Responsive Rows

Columns must reside inside a row to be fully responsive.

Class Description
row Defines a padding-less container for responsive columns.
col Defines a column with sub classes

col has the following sub classes:

Columns for small screens (typical smart phones):

Class Description
s1 Defines 1 of 12 columns (width:08.33%) for small screens
s2 Defines 2 of 12 columns (width:16.66%) for small screens
s3 Defines 3 of 12 columns (width:25.00%) for small screens
s4 Defines 4 of 12 columns (width:33.33%) for small screens
s5-s11  
s12 Defines 12 of 12 columns (width:100%). Default for small screens

Columns for medium screens (typical tablets):

Class Description
m1 Defines 1 of 12 columns (width:08.33%) for medium screens
m2 Defines 2 of 12 columns (width:16.66%) for medium screens
m3 Defines 3 of 12 columns (width:25.00%) for medium screens
m4 Defines 4 of 12 columns (width:33.33%) for medium screens
m5-m11   
m12 Defines 12 of 12 columns (width:100%). Default for medium screens

Columns for large screens (typical laptops):

Class Description
l1 Defines 1 of 12 columns (width:08.33%) for large screens
l2 Defines 2 of 12 columns (width:16.66%) for large screens
l3 Defines 3 of 12 columns (width:25.00%) for large screens
l4 Defines 4 of 12 columns (width:33.33%) for large screens
l5-l11  
l12 Defines 12 of 12 columns (width:100%). Default for large screens)

Example

<div class="row">
  <div class="col m4"><p>m4</p></div>
  <div class="col m4"><p>m4</p></div>
  <div class="col m4"><p>m4</p></div>
</div>

<div class="row">
  <div class="col m3"><p>m3</p></div>
  <div class="col m3"><p>m3</p></div>
  <div class="col m3"><p>m3</p></div>
  <div class="col m3"><p>m3</p></div>
</div>
Try It Yourself »

Example using containers

<div class="container">

<div class="row">
  <div class="col container m4"><p>m4</p></div>
  <div class="col container m4"><p>m4</p></div>
  <div class="col container m4"><p>m4</p></div>
</div>

<div class="row">
  <div class="col container m3"><p>m3</p></div>
  <div class="col container m3"><p>m3</p></div>
  <div class="col container m3"><p>m3</p></div>
  <div class="col container m3"><p>m3</p></div>
</div>

</div>
Try It Yourself »

Example using percent

<div class="row">
    <div class="col" style="width:20%"><p>20%</ p></div>
    <div class="col" style="width:60%"><p>60%</ p></div>
    <div class="col" style="width:20%"><p>20%</ p></div>
lt;/div>
Try It Yourself »

Example using rest

<div class="row">
    <div class="col" style="width:75px"><p>75px</ p></div>
   <div class="rest"><p>rest</p></ div>
</div>
Try It Yourself »