Getting Started

Kimochi.css refers to Japanese "気持ちいい"(kimochi ii), meaning feeling good.
It aims to help developers to dress up web pages with love in a simple way.
The source code of Kimochi.css is available on Github.

Browser support

Kimochi.css is built to work best with the latest desktop browsers, meaning some lagging browsers may not support some advanced CSS effects in this CSS kit. Specifically, Kimochi.css supports the latest version of the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer (partly 8 and newer)

Unfortunately, it should be noted that Internet Explorer 7 and older version is not supported by Kimochi.css. It means you need to fix the compatibility by yourself if you insist on using Kimochi.css in those lagging-browser-oriented projects.

How to Use

Kimochi.css has only ONE pure CSS file, no extra JavaScript and images. Simply download it to your server or localhost before coding.

Download Kimochi.css

Then include Kimochi.css between <head> and </head>.

<link rel="stylesheet" href="//your-site.com/your-css-path/kimochi.css" />

Now enjoy your "kimochi ii" styling.

Tutorial

Here is a simple tutorial about how to create a div box and a blue button.
The <div> box is going to have a dashed border .bd .dashded with 4 pixels border radius .radius-4, and we set 1 unit (12 pixels) padding .pd for it to make the inner elements have more space.
Then we put some text in <p>, and create button using <a>. To make the spacing between text and button larger, we apply class .mb-1 to <p> to set 1 unit (12 pixels) bottom margin. As for the button, we use .button to make the <a> look like a button, and use .button-blue to color it.

HTML

<div class="bd dashed pd-1 radius-4">
  <p class="mb-1">
    Click the button to visit my home page!
  </p>
  <a class="button button-blue" href="#">
    Home Page
  </a>
</div>

Result

Click the button to visit my home page!

Home Page

Equal to CSS

div { border: 1px dashed #DDD; padding: 12px; border-radius: 4px; }
div p { margin-bottom: 12px; }
div a { color: #FFF; background-color: #5ABAF8; border-radius: 4px; /* and some other CSS for a button... */ }

This tutorial shows that Kimochi.css provides multiple CSS classes combinations to compose complete components, even without writing any additional styles.

CSS

Kimochi.css is a modularized CSS kit rather than an object-oriented CSS framework. It encourages developers to combine separate CSS classes together in HTML to make styles, instead of writing additional styles for every components. The target of Kimochi.css is to write less CSS.

The work of Kimochi.css can be divided into three parts:

  1. It defines some basic style classes for global elements' usage.
    These basic classes can be combined in HTML to make different styles.
  2. Some special HTML elements are re-styled to make them more beautiful.
    Such as <table> and <input>.
  3. Additional component styles are also provided.
    So you don't need to write a navigation bar again and again.

Typography

Combinable and Chinese-friendly CSS phrases are provided for typesetting.

Headings

Standard heading tags from <h1> to <h6> and CSS classes from .h1 to .h6 are all available.

36px

.h1 Kimochi.css Heading 中文標題 日本語タイトル

30px

.h2 Kimochi.css Heading 中文標題 日本語タイトル

24px

.h3 Kimochi.css Heading 中文標題 日本語タイトル

18px

.h4 Kimochi.css Heading 中文標題 日本語タイトル

14px
.h5 Kimochi.css Heading 中文標題 日本語タイトル
12px
.h6 Kimochi.css Heading 中文標題 日本語タイトル
<h1>...</h1>
<h2>...</h2>
<h3>...</h3>
<h4>...</h4>
<h5>...</h5>
<h6>...</h6>
<div class="h1">...</div>
<div class="h2">...</div>
<div class="h3">...</div>
<div class="h4">...</div>
<div class="h5">...</div>
<div class="h6">...</div>

Font size

Using .font-{pixel} to set the font size in pixel. The range of {pixel} is every even number from 10 to 36.

Note that the global font size is 14px and global line height is 1.0 (100%), which are both set in <body>.

Example: Typical sizes

.font-10   .font-14   .font-16   .font-20   .font-24   .font-28   .font-32   .font-36
<span class="font-10">...</span>
<span class="font-14">...</span>
<span class="font-16">...</span>
<span class="font-20">...</span>
<span class="font-24">...</span>
<span class="font-28">...</span>
<span class="font-32">...</span>
<span class="font-36">...</span>

Line height

In complex cases, it's difficult to forecast what the line-height of specific elements should be, so Kimochi.css does not define global line-height in em unit. Accordingly, using .lh-{pixel} or .lh-{percentage}p to set the line-height in pixel or in percentage.
The range of {pixel} is 0 and every even number from 10 to 36. And the {percentage} can be 100, 120, 130, 150, 160, 180, 200 and 240.

Example

HTML Line Height
<p class="lh-0"></p> 0px
<p class="lh-16"></p> 16px
<p class="lh-150p"></p> 150% (equal to line-height: 1.5;)
<p class="lh-200p"></p> 200% (equal to line-height: 2;)

Lists

Unordered, Ordered and Unstyled lists are all available. Note that all the lists are not fixed with certain line height, so it would be better to manually add .lh-{n} to the list if necessary. (And the same as padding & margin.)

Example: Unordered list

  • People laugh and people cry
  • Some give up some always try
  • Some say hi some say bye
    • Hi
    • Hi hi
    • Hi hi hi
      • Bye
      • Bye bye
      • Bye bye bye
  • Others may forget you but never I
<ul>
  <li>...</li>
  <li>
    ...
    <ul>
      <li>...</li>
    </ul>
  </li>
</ul>

Example: Ordered list

  1. People laugh and people cry
  2. Some give up some always try
  3. Some say hi some say bye
  4. Others may forget you but never I
<ol>
  <li>...</li>
</ol>

Example: Unstyled list

  • People laugh and people cry
  • Some give up some always try
  • Some say hi some say bye
  • Others may forget you but never I
<ul class="no-list">
  <li>...</li>
</ul>

Code

Undoubtedly <code> is necessary for programmers. A <code> is inline by default, using .code-block to support multiple lines of code. Syntax highlighting is not included in Kimochi.css.

command 1 command 2 command 3 line 1
line 2
...
<code>...</code>

<code class="code-block">...</code>

Font helpers

Kimochi.css provides some other font-related CSS phrases for typesetting.

Class Refers to CSS
.align-center text-align: center;
.align-left text-align: left;
.align-right text-align: right;
.weight-bold font-weight: bold;
.weight-normal font-weight: normal;

Colors

Variety of colors are available for font and containers. In this part, only some generally used color options are listed, more color options for certain components can be seen in other section.

Font colors

Using .font-{color} to color text.

.font-black
.font-blue
.font-blue-light
.font-gray
.font-gray-dark
.font-green
.font-orange
.font-purple
.font-purple-light
.font-pink
.font-red
.font-white
.font-yellow
<div class="font-black">.font-black</div>
<div class="font-blue">.font-blue</div>
<div class="font-blue-light">.font-blue-light</div>
<div class="font-gray">.font-gray</div>
<div class="font-gray-dark">.font-gray-dark</div>
<div class="font-green">.font-green</div>
<div class="font-orange">.font-orange</div>
<div class="font-purple">.font-purple</div>
<div class="font-purple-light">.font-purple-light</div>
<div class="font-pink">.font-pink</div>
<div class="font-red">.font-red</div>
<div class="font-white">.font-white</div>
<div class="font-yellow">.font-yellow</div>

Background colors

Using .bg-{color} to color containers' background. Anchors <a> in the containers will be colored as well while the normal text will not. So you need to manually add .font-{color} to the colored containers if necessary.

blue
link
blue light
link
green
link
orange
link
purple
link
purple light
link
pink
link
red
link
yellow
link
gray
link
gray dark
link
gray light
link
white
link
black
link
<div class="bg-black">...</div>
<div class="bg-blue">...</div>
<div class="bg-blue-light">...</div>
<div class="bg-gray">...</div>
<div class="bg-gray-dark font-white">...</div>
<div class="bg-gray-light">...</div>
<div class="bg-green">...</div>
<div class="bg-orange">...</div>
<div class="bg-pink">...</div>
<div class="bg-purple font-white">...</div>
<div class="bg-purple-light">...</div>
<div class="bg-white">...</div>
<div class="bg-red">...</div>
<div class="bg-yellow">...</div>

Layout system

Kimochi.css is based on 12-pixel layout system, which means 1 unit is equal to 12 pixels. And Kimochi.css defines plenty of layout phrases for combination.

Box size

The element size can be fixed by .w-{n} for width and .h-{n} for height.
Currently, the range of {n} is 0 to 12. So you can use .w-0 to .w-12 to define 0px-to-144px width elements. The same as .h-0 to .h-12 for height. Other necessary lengths may be added in the future version.

Example: Setting width

Class Width HTML Result
.w-1 12px <div class="w-1"></div>
 
.w-5 60px <div class="w-5"></div>
 
.w-12 144px <div class="w-12"></div>
 

Percentage is allowed for width by simply adding "p" after the percentage number.

Width 10% 20% 25% 30% 33.33% 40% 50% 60% 66.66% 75% 80% 100%
Class .w-10p .w-20p .w-25p .w-30p .w-33p .w-40p .w-50p .w-60p .w-66p .w-75p .w-80p .w-100p

Box spacing

The box spacing here mainly refers to margin and padding. You can control specific margin or padding sides individually.

Note that ALL the element's box-sizing in Kimochi.css are box-sizing: border-box;, so ALL the lengths of margin, padding and border-width are included in element's total width and height.

Examples

HTML Refers to CSS Range of n
padding
<div class="pd-1"></div> padding: 12px; 0 to 2
<div class="pt-2"></div> padding-top: 24px; 0 to 2
<div class="pb-0"></div> padding-bottom: 0; 0 to 2
<div class="pl-2"></div> padding-left: 24px; 0 to 2
<div class="pr-0"></div> padding-right: 0; 0 to 2
margin
<div class="mg-1"></div> margin: 12px; 0 to 2
<div class="mt-2"></div> margin-top: 24px; 0 to 2
<div class="mb-0"></div> margin-bottom: 0; 0 to 2
<div class="ml-2"></div> margin-left: 24px; 0 to 2
<div class="mr-0"></div> margin-right: 0; 0 to 2

Box position & display

Kimochi.css pulls out the float & position phrases alone so that you can decide how to place each element.

Float

As is common practice, .left and .right are used to control the float direction.

HTML Refers to CSS
<div class="left"></div> float: left;
<div class="right"></div> float: right;

Clear float

There are two ways to clear float: cleared by parent element or by extra element.

I'm parent
I'm left
I'm right

Cleared by Parent Element

<div class="cleared">
  I'm parent
  <div class="left">I'm left</div>
  <div class="right">I'm right</div>

</div>

Cleared by Extra Element

<div>
  I'm parent
  <div class="left">I'm left</div>
  <div class="right">I'm right</div>
  <div class="clear"></div>
</div>

Display helpers

There are some useful display-related phrases for layout control.

Class Refers to CSS
.block display: block;
.inline-block display: inline-block;
.inline display: inline;
.hide display: none;
.relative position: relative;
.absolute position: absolute;
.fixed position: fixed;
.no-overflow overflow: hidden;

Box borders

Bordered box is available for each edge.

HTML Border Result
<div class="bd">box</div> All edges
box
<div class="b-t">box</div> Top
box
<div class="b-b">box</div> Bottom
box
<div class="b-l">box</div> Left
box
<div class="b-r">box</div> Right
box

Grid System

Kimochi.css provides a 12-column grid system. Each column's width is counted by percentage, that is, 1 column width is 8.33%.
Using .col-{n} to create a {n} unit column in .col-box, the range of {n} is 1 to 12.

Example: Normal Grid Layout

.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-1
.col-2
.col-10
.col-4
.col-4
.col-4
.col-6
.col-6
<div class="col-box">
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
  <div class="col-1 bd pd-1">.col-1</div>
</div>

<div class="col-box">
  <div class="col-2 bd pd-1">.col-2</div>
  <div class="col-10 bd pd-1">.col-10</div>
</div>

<div class="col-box">
  <div class="col-4 bd pd-1">.col-4</div>
  <div class="col-4 bd pd-1">.col-4</div>
  <div class="col-4 bd pd-1">.col-4</div>
</div>

<div class="col-box">
  <div class="col-6 bd pd-1">.col-6</div>
  <div class="col-6 bd pd-1">.col-6</div>
</div>

The class .bd refers to border: 1px solid #DDD;, which helps us distinguish each column easily.

By default, the column is float: left;, Kimochi.css enables columns to have left offset or float right. Like common layout methods, simply using .ml-{n} to add {n} unit offset to a column, or using .right to make a column right-floating. The range of {n} is 1 to 11.

Example: Offsetting & Right-floating

.col-2
.col-2 .ml-1
.col-4 .ml-3
.col-3 .ml-3
.col-3 .ml-3
.col-6 .right
<div class="col-box">
  <div class="col-2 bd pd-1">.col-2</div>
  <div class="col-2 ml-1 bd pd-1">.col-2 .ml-1</div>
  <div class="col-4 ml-3 bd pd-1">.col-4 .ml-3</div>
</div>

<div class="col-box">
  <div class="col-3 ml-3 bd pd-1">.col-3 .ml-3</div>
  <div class="col-3 ml-3 bd pd-1">.col-3 .ml-3</div>
</div>

<div class="col-box">
  <div class="col-6 right bd pd-1">.col-6 .right</div>
</div>

Forms

Some commonly used form elements are restyled to meet the flat UI design.

See #Buttons section for form button style.

Basic form

Simply using native form element tags, requiring no extra CSS class. All textual <input> and <textarea> are set to width: 100%; by default, so a wrapper is needed if you are going to fixed the width of them.

<input type="text" placeholder="Email" value="" />

<select multiple>
  <option>Male</option>
  <option>Female</option>
  <option>Unknown</option>
</select>

<textarea rows="4">I'm lazy... zzZZzZz...</textarea>

<label>
  <input type="checkbox" value="1" />Remember me
</label>

<input type="submit" class="button" value="Submit" />

Inline inputs

Add .form-group as wrapper to keep inputs inline and vertically centered.

<div class="form-group mr-1">
  <input type="text" placeholder="Username" value="" />
</div>

<div class="form-group mr-1">
  <input type="text" placeholder="Email" value="" />
</div>

<div class="form-group">
  <label>
    <input type="checkbox" value="1" />Remember me
  </label>
</div>

Disabled inputs

Using disabled="disabled" attribute and then the disabled style will be automatically added. Alternatively, you can use .disabled to apply the same style but not actually disable inputs.

<input disabled="disabled" type="text" placeholder="Email" value="" />

<select multiple disabled="disabled">
  <option>Male</option>
  <option>Female</option>
  <option>Unknown</option>
</select>

<textarea class="disabled" rows="4">I'm editable</textarea>

<label class="disabled">
  <input disabled="disabled" type="checkbox" value="1" />Remember me
</label>

<input disabled="disabled" type="submit" class="button" value="Submit" />

Tables

A <table> has no style by default, which can be used for layout. By adding .table and related classes, a <table> can be styled.

Basic table

Simply add .table class, a table can be styled with striped rows. A basic table is set to width: 100%;.

# Name Sex Email
1 Bob Male bobbbb@gmail.com
2 Alice Female alice.lee@me.com
3 Maiz Unknown mai.zzz@icloud.com
4 Mark Male st.mark@gmail.com
<table class="table">
  <thead>
    <tr>
      <th>...</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>...</td>
    </tr>
  </tbody>
</table>

Bordered table

Using .table-border to add border to a table.

# Name Sex Email
1 Bob Male bobbbb@gmail.com
2 Alice Female alice.lee@me.com
3 Maiz Unknown mai.zzz@icloud.com
4 Mark Male st.mark@gmail.com
<table class="table table-border">
  <thead>
    <tr>
      <th>...</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>...</td>
    </tr>
  </tbody>
</table>

Hover rows

Add .table-hover to enable a hover state on table rows within the <tbody>.

# Name Sex Email
1 Bob Male bobbbb@gmail.com
2 Alice Female alice.lee@me.com
3 Maiz Unknown mai.zzz@icloud.com
4 Mark Male st.mark@gmail.com
<table class="table table-border table-hover">
  <thead>
    <tr>
      <th>...</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>...</td>
    </tr>
  </tbody>
</table>

Components

Kimochi.css provides some commonly used HTML components to reduce the work of front-end engineers. More necessary components will be added in the future version, and all the components are made to keep as simple as possible to use.

Buttons

Colorful button styles are available for <a>, <input>, <button> and even other containers by adding .button and .button-{color} classes.

Example: Basic buttons

<a>Link

Example: Colorful buttons

Example: Small buttons

Example: Disabled buttons

<!-- basic buttons -->
<a class="button" href="#">Link</a>
<input class="button" type="submit" value="input" />
<button class="button">button</button>

<!-- colorful buttons -->
<button class="button button-blue">Button</button>
<button class="button button-gray">Button</button>
<button class="button button-green">Button</button>
<button class="button button-orange">Button</button>
<button class="button button-purple">Button</button>
<button class="button button-red">Button</button>
<button class="button button-yellow">Button</button>

<!-- small buttons -->
<button class="button button-small button-blue">Button</button>
<button class="button button-small button-gray">Button</button>
<button class="button button-small button-green">Button</button>
<button class="button button-small button-orange">Button</button>
<button class="button button-small button-purple">Button</button>
<button class="button button-small button-red">Button</button>
<button class="button button-small button-yellow">Button</button>

<!-- disabled buttons -->
<input class="button" disabled="disabled" type="submit" value="input" />
<button class="button disabled">button</button>
<input class="button button-small" disabled="disabled" type="submit" value="input" />
<button class="button disabled button-small">button</button>

A basic Nav bar .nav contains a header and multiple links, dropdown menus for links are supported. No extra JavaScript required.
Colorful Nav bars are available as well, add .nav-{color} class to change color. The default color of .nav is purple, which is equal to .nav-purple.

<div class="nav">
  <a class="nav-item nav-head" href="#">iBrand</a>
  <a class="nav-item" href="#">Link</a>
  <a class="nav-item" href="#">Link</a>
  <div class="nav-has-menu">
    <a class="nav-item" href="#">Dropdown</a>
    <div class="nav-menu">
      <a class="nav-menu-item" href="#">Link</a>
      <a class="nav-menu-item" href="#">Link</a>
      <a class="nav-menu-item" href="#">Link</a>
    </div>
  </div>
  <a class="nav-item" href="#">Link</a>
  <a class="nav-item right" href="#">Right link</a>
</div>

<div class="nav nav-blue">...</div>

<div class="nav nav-green">...</div>

<div class="nav nav-orange">...</div>

<div class="nav nav-red">...</div>

<div class="nav nav-yellow">...</div>

For the case which puts the navigation bar on the top of the whole page, a large Nav bar .nav-large is the most suitable one.

Example: Large Nav bar with a wrapper

This is content.
The content width is 90%.
If the Nav bar has no wrapper,
the Nav items will align left of <body> but not the content.
<body>

  <div class="nav nav-large">
    <div class="wrapper">
      <a class="nav-item" href="#">Link</a>
    </div>
  </div>

  <div class="content">
    ...
  </div>

</body>

The CSS for .wrapper and .content are the following lines, which is based on your layout.

.content,
.wrapper {
  width: 90%;
  margin: 0 auto;
}

Msg box

Msg box .msg provides contextual feedback messages for typical user actions. .msg-{color} is used for coloring the msg box, and the default color is .msg-purple purple.

Welcome! Hope you have a "kimochi ii" feeling!
Heads up! Your deadline is coming and stop dreaming!
Tips: Coding too much may lead to fail in finding a girlfriend.
Well done! You have finished this project.
Congratulation! You finally get a boyfriend as well!
Error: Fail to make a child, error code [GENDER_MISMATCH].
Warning: Continue coding may lead to loneliness forever.
<div class="msg">...</div>
<div class="msg msg-blue">...</div>
<div class="msg msg-gray">...</div>
<div class="msg msg-green">...</div>
<div class="msg msg-orange">...</div>
<div class="msg msg-red">...</div>
<div class="msg msg-yellow">...</div>

Card box

A card box .card-box is used to create a bordered container in order to distinguish between the box content and the outer background. Necessary layout controls are needed since .card-box just adds a white background and a shadow border to the container.

Note that CSS3 style .border-radius and .box-shadow are required, hence Internet Explorer 8 (and older) can only get a white background box.

Example: Card box in colored background

I'm a card box.
Put your content here.
<div class="bg-blue-light pd-1">
  <div class="card-box pd-1 w-50p">
    ...
  </div>
</div>

About

Kimochi.css is built based on author's personal preference. One of the main purpose of this CSS kit is to write less specific CSS. One can just combine CSS classes together in HTML to make various components for different layouts. Hence, Kimochi.css may be more suitable for personal projects rather than large commercial projects.

License

Kimochi.css is released under the MIT license. Feel free to use it in your projects :)

Changelog

  • v1.1 - 2014.02.15
    • Fixed form elements' bugs.
    • Increase ml-{n} and mr-{n} from 3 to 20.
    • Add w-{20|30|...|100}.
  • v1.0 - 2013.10.08
    First version released.