First, let's see a sample layout file in rails, and explain it step by step:
<!DOCTYPE html> <html> <head> <title><%= title %></title> <%= csrf_meta_tag %> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> <%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> <!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]--> <%= stylesheet_link_tag 'custom', :media => 'screen' %> </head> <body> <div class="container"> <header> <%= image_tag("logo.png", :alt => "Sample App", :class => "round") %> <nav class="round"> <ul> <li><%= link_to "Home", '#' %></li> <li><%= link_to "Help", '#' %></li> <li><%= link_to "Sign in", '#' %></li> </ul> </nav> </header> <section class="round"> <%= yield %> </section> </div> </body> </html>
1. rails 3 use html5 as default, as indicated in <!DOCTYPE html>
2. since html5 is too new, some old IE browsers like IE8 don't support totally support it, so we include some javascript code (known as "html5shiv")to work around it.
<!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
this code piece is weird.
it means, this line of script including will only be included if IE version is less than IE9.
[if lt IE 9] is not rails, it is conditional comment supported only by IE. This purpose is just supplying a way to provide code that only work in IE, not any other browsers. This is very useful
3. then
<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]-->
works the same way, if current browser less than IE8, it will include another css file.
This css file fixed many IE-only issues.
4. next, we include another css file, called "custom", to put your custom css, we haven't created it yet.
css is forgiving, even if there is no this file, our page still work fine.
5.next, we put all the contents in to a container div,
<div class="container">
</div>
This is needed by blueprint,
the div tag in html is a generic division, it does nothing but divding the doc into distinct part.
in older html, div tags are used for nearly all site divisions, but html5 adds the "header", "nav" and "section" elements, for divisions common to many apps.
then, there are header and section elements, the header contains the site navigation(nav),
the section element contains the site's main content.
all html elements, including divs and the new html5 elements, can be assigned classed and ids.
these are merely labels, and are useful for styling with CSS. The main differences between classes and ids is that classed can be used multiple times on a page, but ids can only be use once.
<img alt="Sample App" class="round" src="/images/logo.png" />
6. inside the header is a rails helper called "image_tag"
<%= image_tag("logo.png", :alt => "Sample App", :class => "round")%>
note, we also passed a hash as second param,
let's see the html generated:
<img alt="Sample App" class="round" src="/images/logo.png" />
the alt attr is what will be displayed if there is no image.
a. you can see for a img tag, it is not <img></img>
instead, it is <img ....... />
this kind of tag are known as self-closing tags.
b. the alt attr is optional, if you don't specify this param, rails will auto use the file name of the image file, if image doesn't display.
c. rails helpers ofter take options hashes in this way, giving us the flexibility to add arbitrary html options without ever leaving Rails!
7. next is a list of navigation links, using unordered list tag <ul>
link_to is a rails helper to creat links, which will create <a href=""></a> as html.
the 1st argument is the link text.
the 2nd argument is the url, for now we just use "#" means blank link, link to itself. we will fill it with useful url later.
the generated html will be
<nav class="round"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Help</a></li> <li><a href="#">Sign in</a></li> </ul> </nav>
发表评论
-
12.3.3 scaling issue of the status feed
2011-10-30 17:54 826the problem of the implementati ... -
12.3 the status feed
2011-10-30 15:34 8641. we need to get all the micro ... -
12.2 a working follow button with Ajax
2011-10-29 18:10 9161. in the last chapter, in the ... -
12.2 a web interface for following and followers.
2011-10-28 22:14 8851.before we do the UI, we need ... -
12. following user, 12.1 relationship model
2011-10-18 14:29 7571. we need to use a relationshi ... -
11.3 manipulating microposts.
2011-10-17 15:31 9021. since all micropost actions ... -
11.2 show microposts.
2011-10-17 12:01 7071. add test to test the new use ... -
11.1 user micropost -- a micropost model.
2011-10-17 10:43 11111. we will first generate a mic ... -
10.4 destroying users.
2011-10-16 15:47 749in this chapter, we will add de ... -
10.3 showing users list
2011-10-15 20:41 780in this chapter, we will do use ... -
10.2 protect pages.
2011-10-15 15:11 671again, we will start from TD ... -
10.1 updating users.
2011-10-14 18:30 7121. git checkout -b updating-use ... -
9.4 sign out
2011-10-13 15:21 742whew!!!, last chapter is a long ... -
9.3 sign in success.
2011-10-12 15:39 7561. we will first finish the cre ... -
9.1 about flash.now[:error] vs flash[:error]
2011-10-12 15:37 733There’s a subtle difference ... -
9.2 sign in failure
2011-10-12 12:19 663start from TDD!!! 1. requir ... -
9.1 sessions
2011-10-12 10:00 647a session is a semi-permanent c ... -
what test framework should you use?
2011-10-11 16:56 0for integration test, i have no ... -
what test framework should you use?
2011-10-11 16:56 0<p>for integration test, ... -
8.4 rspec integration tests
2011-10-11 16:53 727in integration test, you can te ...
相关推荐
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
铅酸电池失效仿真comsol
Java小程序项目源码,该项目包含完整的前后端代码、数据库脚本和相关工具,简单部署即可运行。功能完善、界面美观、操作简单,具有很高的实际应用价值,非常适合作为Java毕业设计或Java课程设计使用。 所有项目均经过严格调试,确保可运行!下载后即可快速部署和使用。 1 适用场景: 毕业设计 期末大作业 课程设计 2 项目特点: 代码完整:详细代码注释,适合新手学习和使用 功能强大:涵盖常见的核心功能,满足大部分课程设计需求 部署简单:有基础的人,只需按照教程操作,轻松完成本地或服务器部署 高质量代码:经过严格测试,确保无错误,稳定运行 3 技术栈和工具 前端:小程序 后端框架:SSM/SpringBoot 开发环境:IntelliJ IDEA 数据库:MySQL(建议使用 5.7 版本,更稳定) 数据库可视化工具:Navicat 部署环境:Tomcat(推荐 7.x 或 8.x 版本),Maven
Java小程序项目源码,该项目包含完整的前后端代码、数据库脚本和相关工具,简单部署即可运行。功能完善、界面美观、操作简单,具有很高的实际应用价值,非常适合作为Java毕业设计或Java课程设计使用。 所有项目均经过严格调试,确保可运行!下载后即可快速部署和使用。 1 适用场景: 毕业设计 期末大作业 课程设计 2 项目特点: 代码完整:详细代码注释,适合新手学习和使用 功能强大:涵盖常见的核心功能,满足大部分课程设计需求 部署简单:有基础的人,只需按照教程操作,轻松完成本地或服务器部署 高质量代码:经过严格测试,确保无错误,稳定运行 3 技术栈和工具 前端:小程序 后端框架:SSM/SpringBoot 开发环境:IntelliJ IDEA 数据库:MySQL(建议使用 5.7 版本,更稳定) 数据库可视化工具:Navicat 部署环境:Tomcat(推荐 7.x 或 8.x 版本),Maven
springboot124中药实验管理系统设计与实现,含有完整的源码和报告文档
解除劳动合同协议书
快速过滤图像融合Matlab代码.rar
强调图像中内核形状(例如直线)的过滤器Matlab代码.rar
在内网linux服务器安装redis 在Linux环境中离线安装Redis是常见的需求,尤其是在内网服务器上,由于无法直接访问公网,我们需要提前下载Redis的源码包并手动安装。下面将详细解释如何进行这一过程。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
微信小程序StartKitw_xapp-startkit
座位选择微信小程序版本
机械臂代码_Mechanical_arm
图像分割测试视频river-light.mp4
前端分析-2023071100789
labview源码参考示例,可供参考学习使用
MPC跟踪轨迹圆形(以后轴为基准)
MATLAB代码:基于主从博弈的智能小区代理商定价策略及电动汽车充电管理 关键词:电动汽车 主从博弈 动态定价 智能小区 充放电优化 参考文档:《基于主从博弈的智能小区代理商定价策略及电动汽车充电管理》基本复现 仿真平台:MATLAB+CPLEX gurobi平台 优势:代码具有一定的深度和创新性,注释清晰,非烂大街的代码,非常精品 主要内容:代码主要做的是一个电动汽车充电管理和智能小区代理商动态定价的问题,将代理商和车主各自追求利益最大化建模为主从博弈,上层以代理商的充电电价作为优化变量,下层以电动汽车的充电策略作为优化变量,通过优化得出最优电价策略以及动态充电策略,代码出图效果非常好,店主已经对代码进行了深入的加工和处理,出图效果非常好,代码质量非常高,保姆级的注释以及人性化的模块子程序,所有数据均有可靠来源,联系后会直接发您资料,保证您学得会,用的起来,简直是萌新福利
springboot154基于Spring Boot智能无人仓库管理,含有完整的源码和报告文档
Matlab领域上传的视频是由对应的完整代码运行得来的,完整代码皆可运行,亲测可用,适合小白; 1、从视频里可见完整代码的内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作