Style the idea pages using HTML and CSS
Originally created by Alex Liao, @alexliao
Style the idea list page
The default Rails scaffolding allow us to build pages very quickly and get our app working. The design could use some work. For this we’re going to be using Bootstrap again. We’ll be using some existing Bootstrap classes to make our own components, style links and buttons.
Open app/views/ideas/index.html.erb
in your Text Editor and replace all the lines with these lines:
This alone isn’t all the styling we’ll need, but this will show all the ideas in a nice list in a moment. At the top we’ll have a new blue button with the label “Add a new idea”.
Open app/views/ideas/_idea.html.erb
in your Text Editor and replace all the lines with these lines:
This will style each idea in the list to show their idea name as a link to the idea itself, it shows when the idea was last updated, the idea description and a thumbnail of the picture you uploaded.
Visit the http://localhost:3000/ideas page to see your new idea app design.
Explain how the design works line by line. What is HTML, what is CSS and what parts are Bootstrap?
Style the idea detail page
Click the title of an idea, and you will be brought to the details page of the idea. This still partially uses scaffold generated by Rails, and may look a bit broken right now. Let’s improve the design.
Open app/views/ideas/show.html.erb
in your text editor and replace all lines with
The new page should look a lot better and a lot like how the ideas are shown on the index page. The actions you can perform on the idea now also are shown in highly visible buttons below the idea details.
Explain how the design works line by line. What is HTML, what is CSS and what parts are Bootstrap?
References
To style the pages we’ve used the following Bootstrap components. Check out the documentation to learn more.
What next?
Did the design and styling catch your eye? Do you want to unleash your inner designer and style more pages?
- Use your new knowledge to design the new idea form located at
app/views/ideas/_form.html.erb
- Add more design to the other pages as you wish.
If you’re ever stuck during a guide, please ask your coach for help and also consult this handy cheatsheet for Ruby, Rails, the console, the Text Editor etc.
Guides
- Guide 1: Start of the guide
- Guide 2: Get to know the tools
- Guide 3: Guide to install Rails
- Guide 4: Build Your First App
- Guide 5: Style your app using HTML and CSS
- Guide 6: Add a new page to your app
- Guide 7: Add a new homepage to your app
- Guide 8: Add picture uploads
- Guide 9: Push Your App to GitHub
- Guide 10: Put your app online with one of these services:
- Guide 11: Style the idea pages using HTML and CSS (Current page!)
- Guide 12: Add comments to your app
- Guide 13: Create picture thumbnails
- Guide 14: Test your app with RSpec