ruby on rails 再探

(1)标记一下:这个貌似蛮好的东西,先收着http://twitter.github.com/bootstrap/

(2)条件注释判断浏览器<!--[if !IE]><!--[if IE]><!--[if lt IE 6]><!--[if gte IE 6]>
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6可识别 <![endif]-->
<!--[if lt IE 6]> IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
<!--[if IE 8]> 仅IE8可识别 <![endif]-->
<!--[if IE 9]> 仅IE9可识别 <![endif]-->

(3)ID和Class  

All HTML elements can be assigned both classes and ids; these are merely labels, and are useful for styling with CSS 。

The main difference between classes and ids is that classes can be used multiple times on a page, but ids can be used only once. 

<div class="container">
  <%= yield %>
</div>
the yield method inserts the contents of each page into the site layout

<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %>

ruby中用来图片链接的方法,其中alt为没有图片时显示的内容,we used the image_tag helper, Rails finds it automatically using the asset pipeline。所以就算在app/assets/images下的图片也可以找到。

 <%= render 'layouts/header' %>

自动去调用app/views/layouts/_header.html.erb而已。

assets在哪,是什么?

app/assets: assets specific to the present application

lib/assets: assets for libraries written by your dev team
vendor/assets: assets from third-party vendors


he three most common cases are .scss for Sass, .coffee for CoffeeScript, and .erb for embedded Ruby (ERb). scss是css的一个超集,是他的一种补充,并不是一种新的语法。它里面可以用nesting嵌套和variable变量。

$grayMediumLight就是一个变量,在之前可以定义 $grayMediumLight: #eaeaea;
footer {
  margin-top: 45px;
  padding-top: 5px;
  border-top: 1px solid $grayMediumLight;
  color: $grayLight;
  a {
    color: $gray;
    &:hover { 
      color: $grayDarker;
    }
  }  
  small { 
    float: left; 
  }
  ul {
    float: right;
    list-style: none;
    li {
      float: left;
      margin-left: 10px;
    }
  }
}
 

<%= link_to "About", about_path %>  可以调用的原因,route处有了以下代码

match'/about',to:'static_pages#about' 自动创建了以下两个东西

about_path => '/about'about_url  => 'http://localhost:3000/about'

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值