技術をかじる猫

適当に気になった技術や言語、思ったこと考えた事など。

ヘッダの見た目をかっこ良くする。

ヘッダとか色々用意してみた。教科書は、O'Reillyの「Building Android Apps with HTML, CSS, and JavaScript」日本語版はまだ無い。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="screen.css" />
    <meta name="viewport"
        content="width=device-width,user-scalable=yes,
            initial-scale=1.0, maximum-scale=3.0" />
    <title>index</title>
</head>
<body>
    <div id="container">
        <div id="header">
            <h1><a href="http://www.white-azalea.net/">Azalea's Study page.</a></h1>
            <div id="utility">
                <ul>
                    <li><a href="about.html">About</a></li>
                    <li><a href="http://d.hatena.ne.jp/white-azalea/">Blog</a></li>
                </ul>
            </div>
        </div>

        <div id="content">
            <p>Sorry, contents and projects are deleted.<br />
            Now create azalea's experiments and studing pages.</p>
        </div>
    </div>
</body>
</html>

で、CSSをこんなことしてみる。

body {
    background-color: #ddd;
    color: #222;
    font-size: 14px;
    margin: 0;
    padding: 0;
}

#header h1 {
    margin: 0;
    padding: 0;
}

#header h1 a {
    /* drawing as block */
    background-color: #ccc;
    border-bottom: 1px solid #666;
    color: #222;
    display: block;
    font-size: 20px;
    font-weight: bold;
    padding: 10px 0;
    text-align: center;
    text-decoration: none;
}

ここまでは普通のCSSそのまま。ヘッダ部分にもう一声入れる。

#header h1 a {
    /* drawing as block */
    background-color: #ccc;
    border-bottom: 1px solid #666;
    color: #222;
    display: block;
    font-size: 20px;
    font-weight: bold;
    padding: 10px 0;
    text-align: center;
    text-decoration: none;
    
    /* draw shadow in text */
    text-shadow: 0px 1px 1px #fff;
    /* draw background as linear. only webkit(chrome/iOS/Android) */
    background-image: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#999));
}

文字のまわりに影を入れて、背景イメージに webkit 特有のスタイル指定を行う。
見た目どうなるかは、こっち


さらに、ヘッダのリンクも、もう少しかっこよくする。

#header ul {
    list-style: none;
    margin: 10px;
    padding: 0;
}

#header ul li a {
    background-color: #fff;
    border: 1px solid #999;
    color: #222;
    display:block;
    font-size:17px;
    font-weight: bold;
    margin-bottom: -1px;
    padding: 12px 10px;
    text-decoration: none;
}

#header ul li:first-child a {
    -webkit-border-top-left-radius: 8px;
    -webkit-border-top-right-radius: 9px;
}

#header ul li:last-child a {
    -webkit-border-bottom-left-radius: 8px;
    -webkit-border-bottom-right-radius: 9px;
}

Webkit 命令を使ってボーダーの角を丸める。コレがどう見えるかというと、リスト状のボタンに見える。
今日はここまで。