Top Interview Questions
Bootstrap is a free, open-source front-end framework used to design and develop responsive and mobile-first websites and web applications. It provides predefined CSS, JavaScript, and HTML components that help developers quickly create visually appealing and consistent web interfaces without writing CSS from scratch.
Originally developed by Mark Otto and Jacob Thornton at Twitter in 2010, Bootstrap was designed to standardize tools across internal projects and reduce inconsistencies caused by different design approaches. Today, Bootstrap is one of the most popular front-end frameworks in web development, widely used by professionals and beginners alike.
Responsive Design:
Bootstrap’s grid system ensures websites look great on desktops, tablets, and mobile devices without extra coding.
Time-Saving:
Developers can use prebuilt components like buttons, navbars, modals, and forms, reducing development time.
Consistency Across Browsers:
Bootstrap is tested across major browsers such as Chrome, Firefox, Safari, and Edge, ensuring uniform appearance.
Ease of Learning:
Its simple syntax and comprehensive documentation make it beginner-friendly.
Integration with JavaScript Plugins:
Bootstrap includes built-in JavaScript plugins for modals, tooltips, carousels, and alerts.
Community Support:
Being open-source, Bootstrap has an active community that contributes themes, templates, and third-party extensions.
2010: Bootstrap was created internally at Twitter to standardize design patterns.
August 2011: Version 1.0 was publicly released as an open-source project on GitHub.
2013-2018: Versions 2.x and 3.x introduced mobile-first design, responsive grids, and custom theming.
2018: Bootstrap 4 introduced a flexbox-based grid system, enhanced components, and improved utilities.
2022: Bootstrap 5 removed jQuery dependency, enhanced CSS custom properties, and improved accessibility.
Mobile-First Design:
Bootstrap follows a mobile-first approach, meaning styles are optimized for smaller screens before scaling up to larger devices.
Responsive Grid System:
A 12-column flexible grid system enables layouts to adjust dynamically based on screen size.
Predefined CSS Classes:
Includes classes for typography, colors, buttons, tables, forms, alerts, and other UI elements.
Reusable Components:
Components such as modals, dropdowns, carousels, badges, and tooltips are ready to use and customizable.
JavaScript Plugins:
Provides interactive elements like sliders, popovers, and accordions without needing external libraries (Bootstrap 5 removed jQuery dependency).
Customizable Themes:
Developers can override default CSS or use Bootstrap variables to create unique themes.
Cross-Browser Compatibility:
Works consistently across Chrome, Firefox, Safari, Edge, and Internet Explorer 10+.
Utility Classes:
Offers helper classes for spacing, alignment, visibility, text formatting, and display control.
Bootstrap has a modular architecture, consisting of three main layers:
Provides core styling for typography, grids, forms, buttons, tables, and other components.
Includes utility classes for margin, padding, text alignment, colors, and responsive display.
Supports customization using Sass variables for colors, breakpoints, and sizes.
Adds interactivity to components like modals, dropdowns, tooltips, carousels, and collapsible elements.
Bootstrap 5 uses vanilla JavaScript, eliminating dependency on jQuery.
Divides the page into 12 columns.
Uses containers, rows, and columns for layout structure.
Supports responsive breakpoints: xs, sm, md, lg, xl, xxl.
Layout Components:
Container: Wraps content and provides padding.
Row: Defines a horizontal group of columns.
Column: Determines width and layout of content within a row.
Content Components:
Typography: Headings, paragraphs, lists, and blockquotes.
Images: Responsive images, thumbnails, and figures.
Tables: Styled tables with striped, bordered, and hoverable variants.
Forms:
Input fields, checkboxes, radio buttons, select dropdowns, and validation styles.
Buttons and Button Groups:
Predefined styles for buttons, sizes, and states like active, disabled, and outline.
Navigation:
Navbars, tabs, pills, breadcrumbs, and pagination for consistent website navigation.
Alerts and Notifications:
Alerts, badges, tooltips, popovers, and progress bars.
Modals and Popups:
Built-in modal dialogs for user interaction, confirmations, or forms.
Cards and Media Objects:
Flexible containers for images, text, and links used for blogs, products, and profiles.
Utility Classes:
Margin, padding, display, float, text alignment, color, background, shadows, and borders.
Rapid Development: Quick prototyping with ready-to-use components.
Responsive Design: Automatically adjusts websites to different screen sizes.
Cross-Browser Support: Consistent UI across all major browsers.
Open Source: Free to use with a large community and ecosystem.
Customizable: Sass variables and themes allow branding and design flexibility.
Consistent UI: Provides a uniform look for websites and web apps.
Integration: Compatible with frameworks like Angular, React, Vue, and server-side technologies.
Heavy File Size: Full Bootstrap can add extra CSS/JS if not customized.
Generic Design: Websites using default Bootstrap components may look similar unless customized.
Overhead: For small projects, including the entire library may be unnecessary.
Learning Curve: While easy for basic usage, advanced customization requires knowledge of Sass and JavaScript.
Web Application Development:
Admin dashboards, CRMs, and e-commerce sites.
Landing Pages:
Quickly create visually appealing, mobile-friendly landing pages.
Prototyping:
Rapid prototyping of web layouts and components for client presentations.
Responsive Websites:
Ensures seamless performance across desktops, tablets, and smartphones.
Integration with Frameworks:
Works with React-Bootstrap, Angular Material, and Vue.js projects for front-end consistency.
Use Containers and Grid System Properly:
Organize layouts using .container, .row, and .col-* classes.
Customize via Sass:
Override default variables to match branding and reduce unused CSS.
Optimize Performance:
Include only required components and minified versions to reduce file size.
Responsive Utilities:
Use breakpoint-based classes for visibility, spacing, and alignment.
Combine with JavaScript Plugins:
Use Bootstrap’s JavaScript plugins for interactivity without external libraries.
Accessibility:
Use ARIA attributes and semantic HTML to make components accessible.
Bootstrap 5 and Beyond:
Removed jQuery dependency, modernized grid and utilities, enhanced CSS variables.
Integration with Modern Frameworks:
Works seamlessly with React, Angular, Vue, and server-side rendering technologies.
Component-Based Design:
Move towards modular components for easier integration and scalability.
Enhanced Accessibility:
Continued focus on WCAG compliance and ARIA support for inclusive web design.
Bootstrap is a powerful front-end framework that simplifies web development by providing responsive grids, prebuilt components, and interactive plugins. Its mobile-first approach, cross-browser compatibility, and rapid prototyping capabilities make it a favorite among web developers.
By leveraging Bootstrap, developers can create professional, consistent, and responsive websites and web applications quickly while minimizing manual CSS coding. With its ongoing updates, rich community support, and integration with modern JavaScript frameworks, Bootstrap continues to be an essential tool in the front-end developer’s toolkit for building modern, scalable, and user-friendly web interfaces.
Answer:
Bootstrap is a popular open-source front-end framework used for developing responsive, mobile-first websites and web applications. It provides CSS, JavaScript, and components for faster UI development.
Answer:
Responsive design using the grid system
Pre-designed UI components: buttons, forms, navbars, modals
Cross-browser compatibility
Customizable with Sass variables
Built-in JavaScript plugins for dynamic UI
| Feature | Bootstrap 4 | Bootstrap 5 |
|---|---|---|
| jQuery dependency | Required | Removed |
| Grid system | 12-column flexbox | Enhanced with gutters |
| Form controls | Older styling | Improved, floating labels |
| Icons | No built-in icons | Bootstrap Icons separate library |
Answer:
A container wraps content and provides proper alignment and padding. Types:
.container – fixed-width, responsive
.container-fluid – full-width, spans entire viewport
Answer:
The grid system allows layout design using rows and columns, based on 12 columns per row. It uses classes like:
.row – defines a horizontal group
.col-* – defines column width
Supports responsive breakpoints: xs, sm, md, lg, xl, xxl.
Answer:
Breakpoints define screen widths for responsive design:
| Size | Class | Width |
|---|---|---|
| Extra small | .col- |
<576px |
| Small | .col-sm- |
≥576px |
| Medium | .col-md- |
≥768px |
| Large | .col-lg- |
≥992px |
| Extra large | .col-xl- |
≥1200px |
| XXL | .col-xxl- |
≥1400px |
.container and .container-fluid?| Feature | .container | .container-fluid |
|---|---|---|
| Width | Fixed | Full width |
| Responsive | Yes | Yes |
| Use case | Standard content | Full-page layouts |
Answer:
Speeds up front-end development
Mobile-first and responsive
Pre-designed UI components
Consistent across browsers
Easy to customize with Sass or CSS overrides
Answer:
Classes are predefined CSS rules applied to HTML elements for styling and layout. Examples:
Text: .text-center, .text-muted
Colors: .bg-primary, .text-success
Spacing: .m-3, .p-2
Display: .d-none, .d-flex
Answer:
A row is a horizontal container used inside a .container or .container-fluid. It organizes columns and ensures proper alignment using flexbox.
Answer:
Columns are used inside rows to divide space horizontally. Classes like .col-md-6 mean the column spans 6 out of 12 parts on medium screens.
Answer:
Fixed Grid: .container with fixed width
Fluid Grid: .container-fluid for full-width layout
Responsive Grid: Uses breakpoint classes to adapt on devices
Answer:
Use .navbar, .navbar-expand-*, and .navbar-collapse classes:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Logo</a>
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active"><a class="nav-link" href="#">Home</a></li>
</ul>
</div>
</nav>
Answer:
Utilities are helper classes for common tasks:
Spacing: .m-3, .p-2
Text alignment: .text-center
Display: .d-none, .d-block, .d-flex
Borders & Colors: .border, .bg-primary
Answer:
Components are prebuilt UI elements:
Buttons: .btn, .btn-primary
Cards: .card, .card-body
Modals: .modal, .modal-dialog
Alerts: .alert, .alert-success
Answer:
Bootstrap forms enhance styling of input fields, labels, checkboxes, and radio buttons.
Example:
<form>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<input type="email" class="form-control" id="email">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
Answer:
A modal is a popup dialog for displaying content over the page.
Classes: .modal, .modal-dialog, .modal-content
Triggers: Buttons or JavaScript events
Answer:
Add the .img-fluid class to make images scale automatically with parent width:
<img src="img.jpg" class="img-fluid" alt="Responsive Image">
Answer:
Bootstrap buttons are pre-styled clickable elements.
Classes: .btn, .btn-primary, .btn-outline-secondary
Sizes: .btn-lg, .btn-sm
Answer:
<table class="table table-striped table-bordered">
<thead>
<tr><th>#</th><th>Name</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>John</td></tr>
</tbody>
</table>
Additional classes: .table-hover, .table-responsive, .table-dark
Answer:
A card is a flexible content container with borders, padding, and headers.
<div class="card" style="width: 18rem;">
<img src="img.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">Card content here.</p>
<a href="#" class="btn btn-primary">Go</a>
</div>
</div>
Answer:
A carousel is a slideshow component for cycling through images or content.
Classes: .carousel, .carousel-inner, .carousel-item
Answer:
The .ratio class makes videos or iframes responsive. Example:
<div class="ratio ratio-16x9">
<iframe src="video.mp4" allowfullscreen></iframe>
</div>
Answer:
Bootstrap Icons are SVG icons for UI design. Usage:
<i class="bi bi-alarm"></i>
Answer:
<div class="row">
<div class="col-md-4">Column 1</div>
<div class="col-md-4">Column 2</div>
<div class="col-md-4">Column 3</div>
</div>
Columns stack vertically on smaller screens
Use breakpoint classes like .col-sm-, .col-lg-
Answer:
Margin: .m-1 to .m-5
Padding: .p-1 to .p-5
Sides: .mt-3 (top), .mb-2 (bottom), .mx-4 (horizontal)
Answer:
Display classes control element visibility and layout:
.d-none, .d-block, .d-inline
.d-flex, .d-inline-flex
Responsive variants: .d-md-none, .d-lg-block
| Display | Description |
|---|---|
| Block | Takes full width, starts on new line |
| Inline | Fits content width, no line break |
| Inline-block | Like inline but supports width/height |
Answer:
Use .modal-dialog with responsive classes:
<div class="modal-dialog modal-lg"> <!-- large modal -->
<div class="modal-dialog modal-sm"> <!-- small modal -->
Answer:
Badges are small count indicators for labels or notifications:
<span class="badge bg-primary">4</span>
Additional: .bg-success, .rounded-pill
Answer:
Alerts are notifications with color-coded messages:
<div class="alert alert-success" role="alert">Success!</div>
Other types: .alert-danger, .alert-warning, .alert-info
Answer:
Tooltips show additional info on hover:
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" title="Tooltip text">
Hover me
</button>
Requires bootstrap.bundle.js for JavaScript
Answer:
Popovers display rich content:
<button type="button" class="btn btn-info" data-bs-toggle="popover" title="Title" data-bs-content="Content here">
Click me
</button>
Answer:
Use .sticky-top class:
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
Answer:
Use grid system inside forms:
<div class="row mb-3">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="Last name">
</div>
</div>
Answer:
Bootstrap 3 had panels (.panel)
Bootstrap 4/5 replaced panels with cards (.card)
Cards are more flexible and modern
Answer:
<ul class="nav nav-tabs">
<li class="nav-item"><a class="nav-link active" data-bs-toggle="tab" href="#home">Home</a></li>
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#profile">Profile</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="home">Home content</div>
<div class="tab-pane fade" id="profile">Profile content</div>
</div>
Answer:
Wrap the table in .table-responsive:
<div class="table-responsive">
<table class="table">...</table>
</div>
Answer:
Include Bootstrap Icons CSS
Use classes:
<i class="bi bi-alarm"></i>
Answer:
Combine badge and button classes:
<button type="button" class="btn btn-primary">
Notifications <span class="badge bg-secondary">4</span>
</button>
Answer:
Input groups add text, buttons, or icons inside input fields:
<div class="input-group mb-3">
<span class="input-group-text">@</span>
<input type="text" class="form-control">
</div>
.d-none and .visually-hidden?| Class | Description |
|---|---|
.d-none |
Hides element completely (display:none) |
.visually-hidden |
Hides element visually but still accessible for screen readers |
This list covers 40+ rich Bootstrap fresher interview questions, including:
Grid system, containers, rows, columns, breakpoints
Components: modals, cards, tables, navbars, tabs, alerts
Utilities: spacing, display, badges, input groups
Responsive design and real-world examples
Q1: What is Bootstrap?
Answer:
Bootstrap is a front-end framework for developing responsive, mobile-first web pages.
Provides predefined CSS classes, JS components, and utilities for layout, typography, forms, buttons, modals, and navigation.
Q2: Difference between Bootstrap 3 and Bootstrap 4
Answer:
| Feature | Bootstrap 3 | Bootstrap 4 |
|---|---|---|
| Grid system | 12-column, fixed | 12-column, flexbox-based |
| Components | Limited | Enhanced with cards, flex utilities |
| Browser support | IE8+ | IE10+ |
| Media queries | px-based | rem/em, mobile-first |
| Sass | No | Yes (preprocessed CSS) |
Q3: What are the advantages of using Bootstrap?
Answer:
Responsive design out-of-the-box.
Cross-browser compatibility.
Prebuilt components and utilities.
Faster development with mobile-first approach.
Consistency across UI elements.
Q4: What are the key features of Bootstrap 4?
Answer:
Flexbox grid system
Cards component
Utility classes (spacing, colors, display)
Responsive breakpoints
Customizable Sass variables
Built-in JS plugins (modal, carousel, tooltip)
Q5: What is the difference between Bootstrap and other frameworks like Foundation or Materialize?
Answer:
Bootstrap: Widely adopted, mobile-first, flexible, large community.
Foundation: More semantic, enterprise-oriented, slightly complex.
Materialize: Follows Material Design principles; good for modern UI look.
Q6: What is the Bootstrap grid system?
Answer:
A 12-column system used to structure page layouts.
Responsive: adjusts automatically for xs, sm, md, lg, xl, xxl breakpoints.
Uses containers, rows, and columns.
Q7: What is the difference between .container and .container-fluid?
Answer:
| Class | Description |
|---|---|
.container |
Fixed-width container with responsive breakpoints |
.container-fluid |
Full-width container spanning entire viewport |
Q8: Difference between .row and .col classes
Answer:
.row – Creates horizontal group of columns with negative margins for alignment.
.col – Defines column width inside a row; can use .col-md-6 for half-width on medium screens.
Q9: Explain Bootstrap breakpoints
Answer:
| Breakpoint | Class prefix | Width |
|---|---|---|
| Extra small | .col- |
<576px |
| Small | .col-sm- |
≥576px |
| Medium | .col-md- |
≥768px |
| Large | .col-lg- |
≥992px |
| Extra large | .col-xl- |
≥1200px |
| Extra extra large | .col-xxl- |
≥1400px |
Q10: Difference between fixed and fluid grid
Answer:
Fixed: .container – max-width changes at breakpoints.
Fluid: .container-fluid – always full-width, no fixed max width.
Q11: What is the difference between .col and .col-auto?
Answer:
.col – Column width adjusts equally to fill row.
.col-auto – Column width adjusts to content width only.
Q12: How does Bootstrap handle column ordering?
Answer:
Use flexbox order classes: .order-1, .order-md-2 etc.
Example:
<div class="row">
<div class="col order-2">Second on mobile</div>
<div class="col order-1">First on mobile</div>
</div>
Q13: What is a Navbar in Bootstrap?
Answer:
Responsive navigation bar.
Classes: .navbar, .navbar-expand-lg, .navbar-light, .navbar-dark.
Supports dropdowns, brand logos, toggler button for mobile.
Q14: What are Cards in Bootstrap 4?
Answer:
Replaces panels, wells, and thumbnails from Bootstrap 3.
Flexible container for text, images, links, headers, footers.
Example:
<div class="card" style="width: 18rem;">
<img src="img.jpg" class="card-img-top">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">Some text</p>
</div>
</div>
Q15: Difference between Modals and Tooltips
Answer:
Modal: Dialog box overlay, used for user interaction.
Tooltip: Small hover pop-up with extra information.
Implementation: JS plugins .modal(), .tooltip().
Q16: What are Bootstrap Alerts?
Answer:
Contextual feedback messages: .alert, .alert-success, .alert-danger.
Can be dismissible using .alert-dismissible and .close button.
Q17: What is Carousel in Bootstrap?
Answer:
A slideshow component for cycling through images, text, or custom content.
Requires .carousel, .carousel-inner, .carousel-item classes.
Q18: Explain Bootstrap Badges and Labels
Answer:
Badges: .badge – small counters or labels attached to text/buttons.
Labels (deprecated) replaced by badges.
Example: <span class="badge badge-primary">4</span>
Q19: Difference between Button groups and Button toolbar
Answer:
Button group: .btn-group – groups buttons horizontally/vertically.
Button toolbar: .btn-toolbar – groups multiple button groups together for layout flexibility.
Q20: Explain Bootstrap Dropdowns
Answer:
Toggleable menus for links or actions.
Classes: .dropdown, .dropdown-toggle, .dropdown-menu.
Supports hover and click triggers, responsive behavior.
Q21: What are Bootstrap utility classes?
Answer:
Classes for spacing, display, colors, borders, flexbox.
Examples:
Margin: .m-3, .mt-2
Padding: .p-4, .px-2
Text color: .text-primary, .text-muted
Q22: Difference between .d-block, .d-flex, .d-inline
Answer:
| Class | Description |
|---|---|
.d-block |
Display block |
.d-flex |
Display flex |
.d-inline |
Display inline |
.d-none |
Hide element |
Q23: How do you use Bootstrap spacing utilities?
Answer:
Syntax: {property}{sides}-{size}
Property: m = margin, p = padding
Sides: t=top, b=bottom, l=left, r=right, x=horizontal, y=vertical, blank=all
Size: 0-5
Example: .mt-3 → margin-top 1rem, .px-2 → padding-left/right 0.5rem
Q24: How to align elements using Bootstrap Flexbox utilities?
Answer:
Use classes like:
.d-flex → enable flex
.justify-content-center, .justify-content-between → horizontal alignment
.align-items-center, .align-items-end → vertical alignment
Q25: How do you hide/show elements responsively?
Answer:
Display classes with breakpoints:
<div class="d-none d-md-block">Visible on md+</div>
<div class="d-block d-md-none">Visible on sm</div>
Q26: What are Bootstrap form controls?
Answer:
Standardized inputs: <input>, <textarea>, <select> with .form-control.
Ensures consistent styling and spacing.
Q27: Difference between .form-inline and .form-horizontal
Answer:
.form-inline: Elements arranged horizontally, suitable for small forms.
.form-horizontal: Labels and inputs arranged side by side, often using grid classes.
Q28: How do you style checkboxes and radio buttons in Bootstrap 4?
Answer:
Use .custom-control classes:
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="check1">
<label class="custom-control-label" for="check1">Option</label>
</div>
Q29: How to create input groups?
Answer:
Combine inputs with text, icons, buttons using .input-group:
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Username">
</div>
Q30: How do you implement validation in Bootstrap 4 forms?
Answer:
Use .was-validated on <form> and .is-invalid / .is-valid on inputs.
Example:
<input type="text" class="form-control is-invalid" required>
<div class="invalid-feedback">Please enter a value</div>
Q31: What is mobile-first design in Bootstrap?
Answer:
Base styles target mobile devices.
Breakpoints apply progressively for larger screens (sm, md, lg, xl).
Q32: How do you make images responsive?
Answer:
Use .img-fluid → max-width: 100%, height auto.
<img src="img.jpg" class="img-fluid" alt="Responsive image">
Q33: How do you make tables responsive?
Answer:
Wrap table in .table-responsive:
<div class="table-responsive">
<table class="table">...</table>
</div>
Q34: How do you hide/show components based on device size?
Answer:
Use responsive display classes:
.d-none, .d-sm-block, .d-md-none, .d-lg-flex etc.
Q35: How do you implement responsive utilities for text?
Answer:
Use classes like: .text-center, .text-md-left, .text-lg-right.
Q36: How do you customize Bootstrap 4 using Sass?
Answer:
Install Sass version of Bootstrap.
Override variables before importing:
$primary: #ff5733;
@import "bootstrap";
Compile Sass → CSS with custom theme.
Q37: How do you include Bootstrap JS plugins?
Answer:
Include jQuery, Popper.js, Bootstrap JS in correct order.
Initialize plugins via data attributes or JS:
<button type="button" class="btn btn-primary" data-toggle="tooltip" title="Tooltip">Hover me</button>
<script>$(function(){$('[data-toggle="tooltip"]').tooltip()})</script>
Q38: What are Bootstrap utility APIs?
Answer:
APIs to generate spacing, display, colors, shadows via Sass maps and loops.
Example: Create custom spacing scales or colors dynamically.
Q39: Difference between Bootstrap 4 and Bootstrap 5 (advanced)
Answer:
| Feature | Bootstrap 4 | Bootstrap 5 |
|---|---|---|
| jQuery | Required | Removed dependency |
| Grid | Flexbox | Flexbox + CSS Grid utilities |
| Forms | Custom controls | Floating labels, simplified forms |
| Icons | No built-in | Bootstrap Icons separate |
| Utilities | Many | Extended, RTL support |
Q40: Best practices in Bootstrap development
Answer:
Use mobile-first, responsive design.
Avoid inline styles; use utility classes.
Keep custom CSS minimal; leverage Sass variables.
Use semantic HTML and proper ARIA attributes.
Optimize page load by using only required components.
Q41: How do you implement sticky headers/footers in Bootstrap?
Answer:
Use .sticky-top for headers:
<nav class="navbar sticky-top">...</nav>
For footer, use .fixed-bottom or flexbox layout for sticky footer.
Q42: How do you create a modal dynamically using JS?
Answer:
var myModal = new bootstrap.Modal(document.getElementById('myModal'));
myModal.show();
Q43: How do you implement cards with grid layout?
Answer:
<div class="row">
<div class="col-md-4"><div class="card">Card 1</div></div>
<div class="col-md-4"><div class="card">Card 2</div></div>
<div class="col-md-4"><div class="card">Card 3</div></div>
</div>
Q44: Difference between .container and .container-xl
Answer:
.container – responsive fixed-width container.
.container-xl – fixed-width container max at 1200px+, overrides default width at extra-large screens.
Q45: How do you implement responsive media objects in Bootstrap 4?
Answer:
Use .media, .media-body, and .align-self-* classes:
<div class="media">
<img src="img.jpg" class="mr-3" alt="...">
<div class="media-body">Content</div>
</div>
Q46: How do you implement a responsive sidebar layout?
Answer:
Use grid + flexbox:
<div class="d-flex">
<div class="bg-light" style="width:250px;">Sidebar</div>
<div class="flex-fill">Main Content</div>
</div>
Sidebar can be hidden on small screens using .d-none .d-md-block.
Q47: How do you optimize Bootstrap for production?
Answer:
Remove unused CSS/JS using PurifyCSS or tree-shaking.
Minify CSS/JS files.
Load CDN versions for faster delivery.
Use only required components via Sass imports.
Q48: Difference between .img-thumbnail and .img-fluid
Answer:
.img-fluid – responsive, scales with container.
.img-thumbnail – responsive + adds border and rounded corners like a thumbnail.
Q49: How do you implement sticky table headers in Bootstrap?
Answer:
Use CSS position: sticky with table wrapper:
thead th { position: sticky; top: 0; background: #fff; }
Q50: How do you create a responsive pricing table in Bootstrap 4?
Answer:
Use grid and cards for columns:
<div class="row">
<div class="col-md-4"><div class="card">Basic</div></div>
<div class="col-md-4"><div class="card">Pro</div></div>
<div class="col-md-4"><div class="card">Enterprise</div></div>
</div>
Use .text-center, .btn, and spacing utilities for styling.