Bootstrap for Rails (2015)
Bootstrap 3 和 Rails 4(样例用的是Ruby 2.1.1,Rails 4.1.4)
Table of Contents
Preface 1
Chapter 1: Introducing Web Application Development in Rails 7 Why Bootstrap with Rails? 8 Setting up a Todo application in Rails 8 Analyzing folder structure of a Rails application 10 Creating views 12 Styling views using CSS 14
Redesigning the Todo application 16
Challenges in styling a Rails application traditionally 23 Summary 24
Chapter 2: Introducing Bootstrap 3 25 What is Bootstrap? 26 Installing Bootstrap in a Rails project 27
Placing Bootstrap files in a Rails project 28 Bootstrap – the Sass way 33 Bootstrap through CDN 35
Summary 36 Chapter 3: Powering a Rails App with Bootstrap's Grid System 37 What is Bootstrap's grid system? 38 Nesting columns 45
Implementing Bootstrap's grid system in a Rails application 46 Summary 54

Table of Contents
Chapter 4: Using Bootstrap's Typography, Buttons,
and Images in a Rails Application 55
Setting up 56 Styling typography 57 Aligning text 61 Text transformation 62 Blockquotes 62 Styling listing elements 64 Creating and styling buttons 67 Which elements are eligible to use Bootstrap's button classes? 70 Styling images in Bootstrap 70 Summary 72
Chapter 5: Reinventing Tables and Forms in Bootstrap 73 Creating Bootstrap tables 73 Creating Bootstrap forms 79 Validation classes in Bootstrap forms 84
Adding Bootstrap table a to our Rails application 85
Adding Bootstrap forms to our Rails application 90
Summary 94 Chapter 6: Creating Navigation Bars 95 Getting started with a navigation bar 95 Navigation bar helper classes 102 Adding a navigation bar to the Rails application 103 Summary 105 Chapter 7: Various Other Bootstrap Components 107 Bootstrap Breadcrumbs 107 The pagination component 108 Bootstrap labels and badges 109 Bootstrap jumbotrons 110 Alerts 111 Creating a progress bar 112 Panels 114 Summary 116 Chapter 8: Working with Bootstrap Modals 117 Getting started with modals 117 Changing Bootstrap's modal size 121 Additional Bootstrap modal features 122
[ ii ]

Table of Contents
Fetching remote content from a Bootstrap modal 123 Using Bootstrap's modal in a Rails application 125 Summary 128
Chapter 9: Creating Image Slideshows with Bootstrap Carousel 129 Getting started with Bootstrap Carousel 130 Adding captions to the slides 138 Customizing Carousel 138 Summary 138
Chapter 10: Creating a Shopping Cart Using Bootstrap Modals 139 Adding a shopping cart symbol 139 Creating a shopping cart using modals 141 Summary 146
Appendix: Adding Custom Styles to a Rails Application 147
Adding Bootstrap-sass to a Rails application 147 Customizing Bootstrap through variables 149
Summary Index
150 151