Developing with Bootstrap
Scenario
Your company has recently decided to standardize all front-end projects using Bootstrap to ensure consistency and maintainability. As part of this initiative, your team has been tasked with refactoring existing projects that were previously styled with custom CSS. You will be revisiting a few of your earlier projects and converting them to use Bootstrap, ensuring that they look consistent and function well across various devices.
You will start with smaller projects, such as a QR Code Component and a Blog Preview Card, and then move on to a more complex, multi-page website project if time allows. This refactoring process is a common task in professional web development and will prepare you to handle similar scenarios in your workplace.
Objectives
By the end of this lab, you will be able to:
- Refactor an existing project using Bootstrap’s utility classes.
- Use Bootstrap components to replace custom-styled elements.
- Apply Bootstrap’s grid system for responsive layouts.
- Demonstrate the ability to leverage Bootstrap documentation for efficient development.
Submission Requirements
Submit your completed lab using the Start Assignment button on the assignment page in Canvas. Your submission should include:
- A link to your GitHub repository or repositories containing the challenge solutions.
Instructions
Fork and Refactor Your Previous Projects
You will revisit the projects you completed in the earlier lab on Frontend Mentor challenges. For each project, fork your previous GitHub repository to use as a starting point. Your task is to refactor your existing code by replacing custom CSS with Bootstrap’s utility classes and components.
Note: With your instructor’s permission, you may use Tailwind in place of Bootstrap for this lab.
Goals for Refactoring:
- Minimize the use of custom CSS.
- Use Bootstrap utility classes (e.g.,
text-center
,p-4
,bg-light
) for styling. - Replace custom components with Bootstrap components (e.g., cards, buttons, navigation).
- Ensure responsive design using Bootstrap’s grid system.
Tip: Keep the Bootstrap documentation open as you work. It is a valuable resource for finding classes and components you may need.
The First Challenge – QR Code Component
Refactor your QR Code Component project using Bootstrap.
Challenge Brief
- Use Bootstrap’s utility classes to replace custom styling for padding, margins, and alignment.
- Use Bootstrap’s card component to simplify the layout.
- Apply Bootstrap’s grid system to center the component on the page.
Task: Open your previous QR Code Component project. Refactor the HTML and CSS to use Bootstrap classes instead of custom styles. Ensure the component looks similar to the original design.
Resources:
Submission Requirements:
- A link to your refactored GitHub repository.
The Second Challenge – Blog Preview Card
Refactor your Blog Preview Card project using Bootstrap.
Challenge Brief
- Replace custom CSS with Bootstrap’s card component and utility classes.
- Use Bootstrap’s text utilities (e.g.,
text-muted
,text-primary
) for consistent typography. - Ensure responsive design using Bootstrap’s grid system and responsive classes (e.g.,
col-md-6
,col-lg-4
).
Task: Open your previous Blog Preview Card project. Refactor the HTML and CSS using Bootstrap. Make use of Bootstrap’s card and typography utilities to achieve a polished look.
Resources:
Submission Requirements:
- A link to your refactored GitHub repository.
The Third Challenge – Space Tourism Multi-Page Website (Optional)
This is a more complex challenge designed to test your ability to refactor a multi-page website using Bootstrap. You are not required to complete this challenge in its entirety, but you should refactor as much as possible within the allotted time, or continue where you left off in your previous lab while using Bootstrap instead of custom CSS.
Challenge Brief
- Replace custom CSS with Bootstrap’s utility classes, components, and grid system.
- Use Bootstrap’s navbar component for navigation.
- Apply Bootstrap’s carousel component if the design includes image sliders.
Task: Open your previous Space Tourism project. Refactor the HTML and CSS using Bootstrap. Focus on implementing the navigation, grid layout, and any components that fit Bootstrap’s offerings.
Resources:
Review and Reflect
Once you have completed refactoring the projects, take a moment to review your work. Consider the following questions:
- What challenges did you face when refactoring your code to use Bootstrap?
- How did using Bootstrap utility classes and components simplify your styling process?
- In what scenarios might you choose not to use Bootstrap and write custom CSS instead?
Summary
In this lab, you refactored previous projects using Bootstrap’s utility classes and components. By leveraging Bootstrap, you streamlined your styling process, reduced custom CSS, and ensured consistent design across your projects. These skills will help you quickly build responsive, polished websites in a professional setting.