シングルクォートとダブルクォートを使い分ける
<?php print ("ダブルクォートで特殊文字の「\\n」を出力します。<br>\n"); print 'シングルクォートの場合は「\n」はそのまま出力されます。'; print ("\n"); ?>
シングルクォートは文字をそのままブラウザに表示させる時
ダブルクォートはコードの記述をする時に使う。
<?php $product = '消しゴム'; print("$product".'を販売しています。'); ?> <br> <?php $product = '消しゴム'; print('$product'.'を販売しています。'); ?>
if文
<?php $num = 0; print('ようこそ'."\n"); print('<hr>'."\n"); if($num <=0){ print('申し訳ありません。在庫切れです。'."\n"); }elseif($num <=3){ print('在庫が希少です。'."\n"); }else{ print('いらっしゃいませ。在庫があります。在庫数は'."$num".'です。'."\n"); } print('<hr>'."\n"); print('ごゆっくりお過ごしください。'."\n"); ?>
タブパネル
http://jquerytools.org/demos/tabs/index.html
ここのライブラリを利用する。
<!DOCTYPE html> <html lang="ja"> <head> <title>jQuery Tools タブパネル</title> <!-- include the Tools --> <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script> <!-- standalone page styling (can be removed) --> <link rel="shortcut icon" href="img/favicon.ico"> <link rel="stylesheet" href="css/tabs.css" type="text/css" media="screen"> </head> <body> <div id="tabpannel"> <ul class="tabs"> <li><a href="#">Tab 1</a></li> <li><a href="#">Tab 2</a></li> <li><a href="#">Tab 3</a></li> </ul><!-- /the tabs --> <div class="panes"> <div>First tab content. Tab contents are called "panes"</div> <div>Second tab content</div> <div>Third tab content</div> </div><!-- /tab "panes" --> </div> <script> // perform JavaScript after the document is scriptable. $(function() { // setup ul.tabs to work as tabs for each div directly under div.panes $("ul.tabs").tabs("div.panes > div"); }); </script> </body> </html>
/*reset-----------------------------------*/ bosy, ul, li, a { margin:0 ; padding:0; } ul { list-style:none; list-style-image:none; } body { padding:50px 80px; font-family:"Lucida Grande","bitstream vera sans","trebuchet ms",sans-serif; } /* get rid of those system borders being generated for A tags */ a:active { outline:none; } :focus { -moz-outline-style:none; } /*tabs--------------------------------------------------------------*/ /* root element for tabs */ ul.tabs { border-bottom:1px solid #666; height:30px; } /* single tab */ ul.tabs li { float:left; } /* link inside the tab. uses a background image */ ul.tabs a { background: url(../img/green.png) no-repeat -420px 0; font-size:15px; font-weight: bold; display:block; height: 30px; line-height:30px; width: 134px; text-align:center; text-decoration:none; color:#888; position:relative; top:1px; } ul.tabs a:active { outline:none; } /* when mouse enters the tab move the background image */ ul.tabs a:hover { background-position: -420px -31px; color:#fff; } /* active tab uses a class name "current". its highlight is also done by moving the background image. */ ul.tabs a.current, ul.tabs a.current:hover, ul.tabs li.current a { background-position: -420px -62px; cursor:default !important; color:#32a778 !important; } /* Different widths for tabs: use a class name: w1, w2, w3 or w2 */ /* width 1 */ ul.tabs a.s { background-position: -553px 0; width:81px; } ul.tabs a.s:hover { background-position: -553px -31px; } ul.tabs a.s.current { background-position: -553px -62px; } /* width 2 */ ul.tabs a.l { background-position: -248px -0px; width:174px; } ul.tabs a.l:hover { background-position: -248px -31px; } ul.tabs a.l.current { background-position: -248px -62px; } /* width 3 */ ul.tabs a.xl { background-position: 0 -0px; width:248px; } ul.tabs a.xl:hover { background-position: 0 -31px; } ul.tabs a.xl.current { background-position: 0 -62px; } /* initially all panes are hidden */ .panes .pane { display:none; } /*tab-panel-------------------------------------------------*/ /* tab pane styling */ .panes div { display:none; padding:15px 10px; border:1px solid #999; border-top:0; height:100px; font-size:14px; background-color:#fff; } #tabpannel { min-width: 500px; }
IE6対策!
Internet Explolar6は…
- カラム落ちする
- 透過PNGが不対応
IE6透過PNG対策は「DD_belatedPNG.js」
- 「DD_belatedPNG_0.0.8a-min.js」ファイルをダウンロードする。
<!--[if IE 6]> <script src="js/DD_belatedPNG_0.0.8a-min.js" type="text/javascript"></script> <script> DD_belatedPNG.fix('img, .png_bg'); </script> <![endif]-->
IE6絡む落ち対策
float:leftしたときのmargin-left、float:right;した時のmargin-rightが指定どおりにいかなくなる。
魔法の言葉「display: inline;」
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>透過PNGのIE6対策</title> <style> body, div, p, imgg { margin: 0; padding: 0; } body { background: url(img/webtreats-paper-pattern-5-brown.jpg) ; } p { text-align: center; } #wrapper { background: #CCC; width: 913px; margin: 30px auto; overflow: hidden; } #contentLeft { background: #CAC; width:356px; float: left; margin-left: 10px; display: inline; } #contentRight { background: #ACC; width:537px; height:454px; float:right; margin-right: 10px; display: inline; } </style> <!--[if IE 6]> <script src="js/DD_belatedPNG_0.0.8a-min.js" type="text/javascript"></script> <script> DD_belatedPNG.fix('img, .png_bg'); </script> <![endif]--> </head> <div id="wrapper"> <div id="contentLeft"> <p><img src="img/penguin_cafe.png" width="356" height="355" alt="ペンギンカフェ"></p> </div> <div id="contentRight"> <p><img src="img/dragon.png" width="537" height="454" alt="龍"></p> </div> <body> </body> </html>