åãã¦ã® Twitter Bootstrapããã®ï¼
ããã«ã¡ã¯ï¼ @taro_tnk ã§ãï¼
ããã㧠twitter bootstarp ã®åå¼·ãã¤ã¤ã
èªåã®ã¡ã¢ã¨ãã¦æ®ãã¦ãããï¼
å¿ è¦ãªãã¡ã¤ã«ãè½ã¨ãã¦ãã
ã¾ãã¯å¿
è¦ãªãã¡ã¤ã«ãè½ã¨ããªããã¨ã«ã¯å§ã¾ããªãã®ã§ã
以ä¸ã®ãµã¤ããã bootstrap 㨠jquery ãè½ã¨ãã¦ãããã
ã»TwitterBoostrap
http://twitter.github.com/bootstrap/
åºæ¬
こちらã®å ¬å¼ãµã¤ããè¦ãªããåå¼·ãã¦ãããï¼
ã¾ãã¯ä»¥ä¸ã®ãã㪠html ãã¡ã¤ã«ãæºåãã¾ãã
<!DOCTYPE html> <html> <head> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> </head> <body> <h1>Hello, world!</h1> <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html>
ãã jquery , boostrap ã® js, css ãèªã¿è¾¼ãã§ãã ãã® html ã
ããããã©ãã©ãèä»ããã¦ãããï¼
ãããã¼ãä»ãã
bootstrap ã§ãããã¼ãä»ããã«ã¯ä»¥ä¸ã®ããã«è¨è¿°ãã¾ãã
<div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#">Title</a> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div> </div>
ããããã¨ãããªæãã®ããã²ã¼ã·ã§ã³ãã¼ãã§ãã¾ãã
ç°¡åã§ããï¼
ãã¨ã¯ããã«ãªãã·ã§ã³çã«ãããããããã¨ãã§ãã¾ãã
fix ã«ãã
ããã²ã¼ã·ã§ã³ã fix ã«ããã«ã¯
div.navbar ã«ä»¥ä¸ã®ããã« .navbar-fixed-top ã追å ããã°OKã§ãã
<div class="navbar navbar-fixed-top">
â» ãããã¼ãæµ®ãã¦ãã¾ãã®ã§ãbody ã« padding-top: 60px; ã¨ãããã¨ã¡ããã©ããã
æåã¨èæ¯ã®è²ãå転ãããï¼é»ã£ã½ããããã¼ã«ããï¼
ãã£ã±ãé»ç³»ã®ã»ããã·ãã¯ã ãããã£ã¦å ´åã¯ä»¥ä¸ã®ããã«ãã¾ãããã
<div class="navbar navbar-inverse">
ãããªæãã
ã¾ãã¹ãã©ã·ã¹ã
丸ã£ã½ãã®ãããã
ãªããããã ã¨åæ¹ã丸ã£ã½ãã®ã§ãããããããã«ã¯ä»¥ä¸ã®ã¯ã©ã¹ã追å ãã¾ãã
<div class="navbar navbar-inverse navbar-static-top">
ãããã
940px ã®ä¸ã«å ¥ãã
ãã®ã¾ã¾ã ã¨å·¦ä¸ã«æåã¨ãå¯ã£ã¡ãã£ã¦ãã®ã§ã940px ã®æ å ã«åãã¾ãã
ãã£ãã®ã½ã¼ã¹ã以ä¸ã®ããã«å¤æ´ãã¦ã
å
容ç©ã div.container ã§å²ã¿ã¾ãã.container ã«ã¤ãã¦ã¯å¾è¿°ã
<div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="brand" href="#">Title</a> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div> </div> </div>
ã¡ãã㨠940px ã®æ å ã«åã¾ã£ã¦ãããã¼ããããªãã¾ããï¼
ã¨ãããããããã¼ã¯ãããªæãã§ã
ãã¨ã¯ç¶æ³ã«å¿ãã¦ãããããã¦ã³ã¨çµã¿åããããããã°ãã£ãã¼ã§ããï¼
ã¡ã¤ã³ã¨ãªã¢ãä½ã
ã¡ã¤ã³ã¨ãªã¢ã¯ä¸çªå¤§æ ã¨ã㦠div.container ã§å²ã¿ã¾ãã
<div class="container"> <h1>Hello World!</div> </div>
æããããè¨ãã¨ããã®ãã©ããã¼ãçãªæãã§ããï¼
ããã 940px ã®ç®±ãä½ãã¾ãã
ã°ãªããã·ã¹ãã ã«ã¤ãã¦
ã¾ãåæã¨ã㦠Bootstrap ã§ã¯ã°ãªããã·ã¹ãã ã¨ãããã®ãæ¡ç¨ãã¦ãã¾ãã
940px ã®ç®±ã 12 ã«ã©ã ã«åå²ãã¦ãã¶ã¤ã³ãã¦ãããã¿ãããªæãã§ãã
詳ããã¯ãã¡ããåèã«ã
Scaffolding · Bootstrap
ã¬ããåå²ï¼
ä»åã¯ãµã¤ãã¡ãã¥ã¼ã¨ã¡ã¤ã³ã«ã©ã ã®ï¼ã«ã©ã æ§æããã£ã¦ã¿ã¾ãããã
ã¨ãããããµã¤ãã¡ãã¥ã¼ã 3/12 ãã¡ã¤ã³ã«ã©ã ã 9/12 ã¨ãã¾ãã
åå²ããã«ã¯åå²ãããã®ã« .span3 ã®ããã«ã
ãspan + 12åã®ãã¡ããã¤ä½¿ããã
ã®ãããªã¯ã©ã¹ãä»ãã¾ãã
ããã¦ãããã .row ã§å²ã¿ã¾ãã
æ¥æ¬èªä¸èªç±ã§ä¸æã説æã§ããªãã®ã§ãã½ã¼ã¹ã§æ¸ãã¨ãããªæãã§ãã
<div class="container"> <div class="row"> <div class="span9"> <h1>Hello, world!</h1> <p>ã¡ã¤ã³ã«ã©ã ã§ãã</p> </div> <div class="span3"> <p>ãµã¤ãã¡ãã¥ã¼ã§ãã</p> </div> </div> </div>
ãã¡ãã div.row ã®ä¸ã«ãã div.span ã®å¾ãã®æ°å¤ã¯ã
足ã㦠12 ã«ãªãããã«ãã¾ãã
ãµã¤ãã¡ãã¥ã¼ãããå°ãæ ¼å¥½è¯ããã
è¦ãç®çã«ï¼ç¨®é¡ã®ããæ¹ãããã¾ãã
- ãã®ï¼
ul.class="nav nav-list" ã§å®ç¾ãã¾ãã
ãããªé¢¨ã«ããã¨
<ul class="nav nav-list well"> <li class="nav-header">ã³ã³ãã³ãï¼</li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> <li class="nav-header">ã³ã³ãã³ãï¼</li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> </ul>
ããã²ã¼ã·ã§ã³ãªã¹ãã«ãªãã¾ãï¼
.well ã¯èæ¯ãè§ä¸¸ã°ã¬ã¼ã«ããããã«ãã£ã¦ã¾ãã
ãã®æ¹æ³ã ã¨ãããªæãã«ãªãã¾ãã
- ãã®ï¼
次ã®æ¹æ³ã¯
ul.nav nav-tabs nav-stacked ã§ããã¾ãã
<ul class="nav nav-tabs nav-stacked"> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> </ul>
ã¡ãªã¿ã«ãããªæãã«ãªãã¾ããã
ï¼ãã£ã¡ã¯ãµã¤ããã¼ã«ããã«ã¯ä¸è¬çãããªãã®ããªï¼ï¼
好ããªæ¹ãé¸ã³ã¾ããã¼
ããã¿ã¼ãä½ã
Bootstrap èªä½ã«ããã¿ã¼çãªãã®ã¯æºåããã¦ãªãã£ã½ãã§ããï¼è¦æ¤è¨¼ï¼ã
ãªã®ã§å
¬å¼ã® Example ã«ãã こちらã®ãã¼ã¸ã®ã¹ã¿ã¤ã«ãã³ãããã¾ãã
html ã«ã¹ã¿ã¤ã«ãç´æ¸ããã¦ãã以ä¸ã®é¨åãã¾ãã£ã¨æã£ã¦ãã¾ãã
<style type="text/css"> /* Sticky footer styles -------------------------------------------------- */ html, body { height: 100%; /* The html and body elements cannot have any padding or margin. */ } /* Wrapper for page content to push down footer */ #wrap { min-height: 100%; height: auto !important; height: 100%; /* Negative indent footer by it's height */ margin: 0 auto -60px; } /* Set the fixed height of the footer here */ #push, #footer { height: 60px; } #footer { background-color: #f5f5f5; } /* Lastly, apply responsive CSS fixes as necessary */ @media (max-width: 767px) { #footer { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; } } /* My Setting CSS -------------------------------------------------- */ body { padding-top: 60px; } </style>
html ãã½ã¼ã¹ãåèã«ä»¥ä¸ã®ããã«ä½ãã¾ãã
- footer 以å¤ã®ã³ã³ãã³ãã div.wrap ã§å²ã
- div#wrap ã®æå¾ã«ç©ºã® div#push ãå ¥ãã
- div#footer ãå ¥ãã
ã½ã¼ã¹ã ã¨ãããªæãã
<div id="wrap"> <div class="container"> <div class="row"> <div class="span9"> ... </div><!-- /span9 --> <div id="sidebar" class="span3"> <ul class="nav nav-list well"> ... </ul> </div><!-- /span3 --> </div><!-- /row --> </div><!-- /container --> <div id="push"></div> </div><!-- /wrap --> <div id="footer"> <div class="container"> <p>ããã¿ã¼ã§ãã</p> </div> </div>
ããããã¨ç¢ºãã«ã§ããã®ã§ããã
ãããã¼ã fixed ã«ããæã«è¿½å ããã body { padding-top: 60px; } ã®ããã§ã
ããã¿ã¼ãã¹ã¯ãã¼ã«ããªãã¨è¡¨ç¤ºã§ããªãç¶æ
ã«ãªã£ã¦ãã¾ãã¾ãã
ãããã調ã¹ã¦ã¿ãã以ä¸ã®ãã㪠gist ãçºè¦ãã¾ããï¼
https://gist.github.com/1918937
ããã
試ãã¦ã¿ãã®ã§ãã div#footer ã®æ¨ªå¹
ã 940px ã«ãªã£ã¦ãã¾ã£ã¦ãã¾ã好ããããªãã®ã§ã
諦ãã¦å
¬å¼ã§ç´¹ä»ããã¦ãããæ¹ã§ãããã¨æãã¾ãã
ã¨ãããã
ã¬ã¤ã¢ã¦ãçãªé¨åããµãã£ã¨ã§ãã¾ããã®ã§ãã¨ããããä»æ¥ã¯ããã¾ã§ã
ä»æ¥ã®ææã¯ãããªæãâ
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> <style type="text/css" media="screen"> <!-- /* Sticky footer styles -------------------------------------------------- */ html, body { height: 100%; /* The html and body elements cannot have any padding or margin. */ } /* Wrapper for page content to push down footer */ #wrap { min-height: 100%; height: auto !important; height: 100%; /* Negative indent footer by it's height */ margin: 0 auto -60px; } /* Set the fixed height of the footer here */ #push, #footer { height: 60px; } #footer { background-color: #f5f5f5; } /* Lastly, apply responsive CSS fixes as necessary */ @media (max-width: 767px) { #footer { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; } } /* My Setting CSS -------------------------------------------------- */ body { padding-top: 60px; } --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="brand" href="#">Title</a> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> </div> </div> </div> <div id="wrap"> <div class="container"> <div class="row"> <div class="span9"> <h1>Hello, world!</h1> <p>ã¡ã¤ã³ã«ã©ã ã§ãã</p> </div><!-- /span9 --> <div id="sidebar" class="span3"> <ul class="nav nav-list well"> <li class="nav-header">ã³ã³ãã³ãï¼</li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> <li class="nav-header">ã³ã³ãã³ãï¼</li> <li><a href="#">ãªã³ï¼</a></li> <li><a href="#">ãªã³ï¼</a></li> </ul> </div><!-- /span3 --> </div><!-- /row --> </div><!-- /container --> <div id="push"></div> </div><!-- /wrap --> <div id="footer"> <div class="container"> <p>ããã¿ã¼ã§ãã</p> </div> </div><!-- /footer --> <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html>
次åã¯ãã¼ãã«ã¬ã¤ã¢ã¦ãããããã¨æã£ã¦ã¾ãã
追伸
ãæ¥æ¬èªä¸èªç±ããã¦æ³£ãã
追è¨
ãã®ï¼æ¸ãã¾ãã â 初めての Twitter Bootstrap その2 〜table編〜