非同期スニペット

「CSS / CSS3」カテゴリーのブログアーカイブ

サイト内検索

Loading

Contact

  • ワサビ株式会社
  • 657-0843
    兵庫県神戸市灘区大石北町7-14
  • TEL. 078-862-5942
  • 受付時間: 平日 -
  • 上記時間外: 070-5503-3830
<< 当月 >>
JavaScriptが無効です。
メールでのお問い合わせは、こちら

Work with us!

私たちのビジネスの成功は、社会に貢献できると確信してます。

ワサビは、才能や情熱を持った方との出会いを待ってます。

インターネットで出来る事、その可能性を仕事にしたい方は、ご連絡ください!

採用の詳細は、こちら

blog (Recent Posts)

Categories

タグクラウド

Archives

制作・運用約款

  • スマートウェブへのリンク

HTMLとCSSについて

投稿日:

ホームページは、文章の構造(段落など)や見栄え(フォントサイズなど)に関する指定とそれらの配置をつかさどるレイアウトに関する指定を組み合わせて作っていきます。前者をHTML、後者をCSSと呼びます。

かつてはHTMLで構造からレイアウトまで担っていましたが、原則としてHTMLは構造に関する部分のみなので、レイアウトに関するCSSと呼ばれる基準が新たにつくられました。

CSSを使うと、フォントや文字の大きさ、文字飾り、行間などの見栄えに関する情報を文書本体(および構造を記述したHTML)から切り離すことができ、ユーザーが複数のレイアウトから適当なものを選択することができます。

CSSの導入の一番のメリットはサイトのメンテナンス性向上です。
複数のHTML文書からCSSファイルに関連付けることで、デザイン変更の際、CSSファイルに手を加えるだけで、そのCSSファイルを参照するすべてのHTML文書のスタイル変更に対応できます。

また、サイトの構造とレイアウトが分離されるため、ページを軽く作ることができ、ページの読み込み速度が速くなります。

藤井Posted by T.fujii

リセットするスタイルシート リセットCSS

投稿日:

今日、弊社のコーダーとCSSリセット(彼女は、初期化と言ってました)の話でちょっと盛り上がりました。

基本、下記の様なコード今までは記述しておりましたが今回このサイトは「初期化なしで行こう」というわたしの判断で初期化の記述をしておりません。

/*初期化*/
body, div, h1, h2, h3, h4, h5, h6, p, dl, dt, dd, ul, ol, li,
brockquote, pre, table, caption, th, td, address,
form, fieldset, legend, object {
  margin: 0;
  padding: 0;
}

h5, h6, pre, table, code, kbd, samp, acronym, input, textarea {
  font-size: 100%;
}

em{
color: #FF0000;
font-style: normal;
font-weight: bold;
}

ul.tokuten{
 margin: 0; padding: 17px;
}

ul.tokuten li{
	list-style-type: disc
}

a {
  border: none;
  text-decoration: none;
}
img {
	margin: 0;
  	padding: 0;
	border: none;
	vertical-align: bottom;
}
p {
  line-height: 1.5em;
  padding: 3px 0 8px 0;
}

ul {
  list-style-position: outside;
  list-style-type: none;
}

ol {
  list-style-position: outside;
}

body {
  background: #EBF3E4;
  font-family: MS UI Gothic sans-serif;
  font-size: 12px;
  color: #666666;
  line-height:1.6em;
}

* html body { /* for IE6 */
  font-size: small;
}

*:first-child+html body { /* for IE7 */
  font-size: small;
}

a {
	color: #666666;
}
a:visited {
	color: #666666;
	text-decoration: none;
}
a:hover {
	color: #666666;
	text-decoration: underline;
}

#container {
	width:820px; margin:0px auto; text-align:left;
}

#header{
	width:820px;
}

#tagline{
	height:25px;
	padding-top:10px;
}
#contact p{
	padding:0px;
	margin:3px 0 3px 0;
}

海外では、YUI(ずっと日本人女性が作ったものだと思ってました)

http://developer.yahoo.com/yui/reset/

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
	margin:0;
	padding:0;
}
table {
	border-collapse:collapse;
	border-spacing:0;
}
fieldset,img {
	border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
	font-style:normal;
	font-weight:normal;
}
ol,ul {
	list-style:none;
}
caption,th {
	text-align:left;
}
h1,h2,h3,h4,h5,h6 {
	font-size:100%;
	font-weight:normal;
}
q:before,q:after {
	content:'';
}
abbr,acronym { border:0;
}

もっとも新しいとされているCSSリセットがNormalize CSSです。

http://necolas.github.com/normalize.css/

こちらでデモもみれらます。

http://necolas.github.com/normalize.css/demo.html

これは、かなり良いです。

結論、使ってませんが。

/*! normalize.css 2011-06-21T18:23 UTC · http://github.com/necolas/normalize.css */

/* =============================================================================
   HTML5 element display
   ========================================================================== */

/*
 * Corrects block display not defined in IE6/7/8/9 & FF3
 */

article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section {
    display: block;
}

/*
 * Corrects inline-block display not defined in IE6/7/8/9 & FF3
 * Known limitation: IE6 will not apply style for 'audio[controls]'
 */

audio[controls],
canvas,
video {
    display: inline-block;
    *display: inline;
    zoom: 1;
}

/* =============================================================================
   Base
   ========================================================================== */

/*
 * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units
 *    http://clagnut.com/blog/348/#c790
 * 2. Keeps page centred in all browsers regardless of content height
 * 3. Removes Android and iOS tap highlight color to prevent entire container being highlighted
 *    www.yuiblog.com/blog/2010/10/01/quick-tip-customizing-the-mobile-safari-tap-highlight-color/
 * 4. Prevents iOS text size adjust after orientation change, without disabling user zoom
 *    www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/
 */

html {
    font-size: 100%; /* 1 */
    overflow-y: scroll; /* 2 */
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* 3 */
    -webkit-text-size-adjust: 100%; /* 4 */
    -ms-text-size-adjust: 100%; /* 4 */
}

/*
 * Addresses margins handled incorrectly in IE6/7
 */

body {
    margin: 0;
}

/*
 * Addresses font-family inconsistency between 'textarea' and other form elements.
 */

body,
button,
input,
select,
textarea {
    font-family: sans-serif;
}

/* =============================================================================
   Links
   ========================================================================== */

a {
    color: #00e;
}

a:visited {
    color: #551a8b;
}

/*
 * Addresses outline displayed oddly in Chrome
 */

a:focus {
    outline: thin dotted;
}

/*
 * Improves readability when focused and also mouse hovered in all browsers
 * people.opera.com/patrickl/experiments/keyboard/test
 */

a:hover,
a:active {
    outline: 0;
}

/* =============================================================================
   Typography
   ========================================================================== */

/*
 * Addresses styling not present in IE7/8/9, S5, Chrome
 */

abbr[title] {
    border-bottom: 1px dotted;
}

/*
 * Addresses style set to 'bolder' in FF3/4, S4/5, Chrome
*/

b,
strong {
    font-weight: bold;
}

blockquote {
    margin: 1em 40px;
}

/*
 * Addresses styling not present in S5, Chrome
 */

dfn {
    font-style: italic;
}

/*
 * Addresses styling not present in IE6/7/8/9
 */

mark {
    background: #ff0;
    color: #000;
}

/*
 * Corrects font family set oddly in IE6, S5, Chrome
 * en.wikipedia.org/wiki/User:Davidgothberg/Test59
 */

pre,
code,
kbd,
samp {
    font-family: monospace, monospace;
    _font-family: 'courier new', monospace;
    font-size: 1em;
}

/*
 * Improves readability of pre-formatted text in all browsers
 */

pre {
    white-space: pre;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/*
 * 1. Addresses CSS quotes not supported in IE6/7
 * 2. Addresses quote property not supported in S4
 */

/* 1 */

q {
    quotes: none;
}

/* 2 */

q:before,
q:after {
    content: '';
    content: none;
}

small {
    font-size: 75%;
}

/*
 * Prevents sub and sup affecting line-height in all browsers
 * gist.github.com/413930
 */

sub,
sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sup {
    top: -0.5em;
}

sub {
    bottom: -0.25em;
}

/* =============================================================================
   Lists
   ========================================================================== */

ul,
ol {
    margin: 1em 0;
    padding: 0 0 0 40px;
}

dd {
    margin: 0 0 0 40px;
}

nav ul,
nav ol {
    list-style: none;
}

/* =============================================================================
   Embedded content
   ========================================================================== */

/*
 * 1. Removes border when inside 'a' element in IE6/7/8/9
 * 2. Improves image quality when scaled in IE7
 *    code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/
 */

img {
    border: 0; /* 1 */
    -ms-interpolation-mode: bicubic; /* 2 */
}

/*
 * Corrects overflow displayed oddly in IE9
 */

svg:not(:root) {
    overflow: hidden;
}

/* =============================================================================
   Figures
   ========================================================================== */

/*
 * Addresses margin not present in IE6/7/8/9, S5, O11
 */

figure {
    margin: 0;
}

/* =============================================================================
   Forms
   ========================================================================== */

/*
 * Corrects margin displayed oddly in IE6/7
 */

form {
    margin: 0;
}

/*
 * Define consistent margin and padding
 */

fieldset {
    margin: 0 2px;
    padding: 0.35em 0.625em 0.75em;
}

/*
 * 1. Corrects color not being inherited in IE6/7/8/9
 * 2. Corrects alignment displayed oddly in IE6/7
 */

legend {
    border: 0; /* 1 */
    *margin-left: -7px; /* 2 */
}

/*
 * 1. Corrects font size not being inherited in all browsers
 * 2. Addresses margins set differently in IE6/7, F3/4, S5, Chrome
 * 3. Improves appearance and consistency in all browsers
 */

button,
input,
select,
textarea {
    font-size: 100%; /* 1 */
    margin: 0; /* 2 */
    vertical-align: baseline; /* 3 */
    *vertical-align: middle; /* 3 */
}

/*
 * 1. Addresses FF3/4 setting line-height using !important in the UA stylesheet
 * 2. Corrects inner spacing displayed oddly in IE6/7
 */

button,
input {
    line-height: normal; /* 1 */
    *overflow: visible;  /* 2 */
}

/*
 * 1. Improves usability and consistency of cursor style between image-type 'input' and others
 * 2. Corrects inability to style clickable 'input' types in iOS
 */

button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
    cursor: pointer; /* 1 */
    -webkit-appearance: button; /* 2 */
}

/*
 * Addresses box sizing set to content-box in IE8/9
 */

input[type="checkbox"],
input[type="radio"] {
    box-sizing: border-box;
}

/*
 * 1. Addresses appearance set to searchfield in S5, Chrome
 * 2. Addresses box sizing set to border-box in S5, Chrome (include -moz to future-proof)
 */

input[type="search"] {
    -webkit-appearance: textfield; /* 1 */
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box; /* 2 */
    box-sizing: content-box;
}

/*
 * Corrects inner padding displayed oddly in S5, Chrome on OSX
 */

input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
}

/*
 * Corrects inner padding and border displayed oddly in FF3/4
 * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/
 */

button::-moz-focus-inner,
input::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/*
 * 1. Removes default vertical scrollbar in IE6/7/8/9
 * 2. Improves readability and aligment in all browsers
 */

textarea {
    overflow: auto; /* 1 */
    vertical-align: top; /* 2 */
}

/* =============================================================================
   Tables
   ========================================================================== */

/*
 * Remove most spacing between table cells
 */

table {
    border-collapse: collapse;
    border-spacing: 0;
}

この記述は、6月21日に更新されたものみたいです。

本サイトにある英文をわたしなりに翻訳してみました。

間違っていたらご指摘ください。

これってどうよ?

  • 他のやつらのとは違って、使い勝手がいいのは残してるよ
  • 多くの要素を標準化したよ
  • バグ修正と有名どころのブラウザの不整合をなんとかした
  • ちょっと改良して使い勝手をよくした
  • ちゃんとコメントいれて説明してるよ

サポートしているブラウザ

Chrome, Firefox 3+, Safari 4+, Opera 10+, Internet Explorer 6+

<ul><li> 横に並べたリストの中央揃え

投稿日:

  • 横並びにしたリストを中央に揃える方法はいくつかあります。

    基本的には、「display: inline-block」を使ってます。

    通常floatでleftやrightなどを使ってますが、「float: center」というプロパティがないので利用してますが、IE7以下やFirefox2に対応していないため、下記のプロパティを追記します。

    display: -moz-inline-box;
    /display: inline;
    /zoom: 1;
    

    下記は、このサイトのグローバルナビゲーションの記述です。

    <blockquote>nav {
    	width: 950px;
    	margin: 0px auto;
    	padding: 0px 10px 0px 10px;
    	overflow: hidden;
    	font-size: 1.5em;
    	font-weight: bold;
    }
    
    	nav ul {
    		text-align:center;
    	}
    
    	nav ul li {
    		list-style: none;
                    display: inline-block;
    		 display: -moz-inline-box;
      		/display: inline;
      		/zoom: 1;
    		padding: 0px 3px 0px 3px;
    	}</blockquote>
    

    他にもやり方は、あると思いますが今のところがこれが一番分かりやすいです。

ページトップへ