lecture Notes Of Class 1: Introduction to Tailwind CSS
Objectives:
- Understand
what Tailwind CSS is and its core principles.
- Learn
how to set up a basic Tailwind CSS project.
- Install
Tailwind CSS via CDN (Content Delivery Network).
- Create
a simple HTML page and apply basic utility classes like
text-center,font-bold, etc.
1.
What is Tailwind CSS?
Tailwind
CSS is a utility-first CSS framework that provides pre-defined
classes to design custom websites quickly. Unlike traditional CSS frameworks
that provide component-based classes (like btn,
card,
etc.), Tailwind allows you to build designs directly in your HTML by using
utility classes. These classes are designed to do one thing—apply a single
style property, such as padding,
margin, font-size, and others.
Key
Features of Tailwind CSS:
- Utility-first approach:
Instead of writing custom CSS, you use utility classes directly in HTML.
- Customizable:
Tailwind allows you to customize your design system using its
configuration file.
- Responsive Design:
Tailwind makes it easy to create responsive designs with its mobile-first
breakpoints.
- Minimal CSS:
Only the CSS you use is compiled, making your CSS file smaller.
Example:
html<div class="text-center font-bold text-lg"> Welcome to Tailwind CSS!</div>
In the
above example:
text-center: Centers the text.font-bold: Makes the text bold.text-lg: Applies a large font size.
2.
Setting up Tailwind CSS
There are
multiple ways to set up Tailwind CSS in a project. The easiest way for
beginners is to use CDN (Content Delivery Network), which
allows you to include Tailwind CSS directly from an online source without
downloading anything to your local system.
Steps
to install Tailwind via CDN:
1.
Create a New HTML File: Open any text editor (like Visual Studio Code,
Sublime Text, or even Notepad), and create a new file named index.html.
2.
Include the Tailwind CDN link: Inside the <head> section of
your HTML, include the Tailwind CDN link. This link will load Tailwind CSS from
the CDN (online).
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Introduction to Tailwind CSS</title> <!-- Tailwind CSS via CDN --> <script src="https://cdn.tailwindcss.com"></script></head><body> <!-- Content Goes Here --></body></html>
3.
Save the File: Save the file as index.html.
3.
Creating a Basic HTML Page with Tailwind Utility Classes
Once
Tailwind CSS is linked to your HTML file, you can start using Tailwind's
utility classes to style your content.
Example
1: Centered Text
Let’s
create a simple HTML page that uses Tailwind utility classes to center some
text and make it bold.
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Example</title> <!-- Tailwind CSS via CDN --> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-100"> <div class="flex justify-center items-center h-screen"> <h1 class="text-4xl font-bold text-blue-600"> Welcome to Tailwind CSS! </h1> </div></body></html>
Explanation
of classes used:
bg-gray-100: Sets the background color of the page to a light gray.flex: Makes the container a flexbox, which is useful for centering content.justify-center: Horizontally centers the content.items-center: Vertically centers the content.h-screen: Makes the container take up the full height of the viewport.text-4xl: Sets the font size to 4 times the base font size.font-bold: Makes the text bold.text-blue-600: Sets the text color to a specific shade of blue.
4.
Tailwind CSS Utility Classes
Tailwind
CSS is built on the concept of utility classes. These are
single-purpose classes that apply specific styles. Below are some commonly used
utility classes in Tailwind:
Text
Utilities:
text-center: Centers text horizontally.text-left: Aligns text to the left.text-right: Aligns text to the right.text-lg: Sets the text size to large.font-bold: Makes the text bold.
Spacing
Utilities:
p-4: Applies padding of1remon all sides.m-4: Applies margin of1remon all sides.mt-4: Adds margin at the top (1rem).ml-4: Adds margin on the left side (1rem).
Background
and Border Utilities:
bg-blue-500: Sets the background color to a blue shade.border: Adds a border around an element.border-2: Sets the border thickness to 2 pixels.rounded: Rounds the corners of the element.
Layout
Utilities:
flex: Makes the element a flex container.grid: Makes the element a grid container.h-screen: Makes the element take up the full height of the screen.
5.
Activities and Hands-on Practice
Now that
you've learned the basic concepts, it's time to practice by building your own
basic web page with Tailwind CSS.
Activity
1: Create a Simple Centered Text Page
1.
Set up your index.html page with Tailwind
CDN.
2.
Create a div
in the body section and apply the following Tailwind classes to center text:
o flex,
justify-center, items-center, h-screen.
3.
Inside the div, add an h1 element with a message
like "Hello, World!" and apply the classes text-3xl, font-semibold.
Activity
2: Experiment with Colors and Spacing
1.
Add another div below the first one.
2.
Apply bg-blue-500,
p-6, and rounded to this new div.
3.
Inside this div, add another heading,
like "This is a Tailwind CSS Box", and use text-white for text color.
6.
Conclusion
In this
class, we learned about Tailwind CSS and how to quickly set it up in our
projects using a CDN. We also practiced creating a basic HTML page and applying
utility classes to style the content. Tailwind’s utility-first approach
provides flexibility and speed in designing web pages, allowing developers to
create custom designs without writing a lot of custom CSS.
Next
Steps: In the
next class, we will dive deeper into more advanced utilities of Tailwind CSS
and explore how to create more complex layouts and responsive designs.
Key
Takeaways:
- Tailwind
CSS is a utility-first CSS framework that helps you style websites quickly
using predefined classes.
- You
can easily set up Tailwind CSS by including the CDN link in your HTML
file.
- Tailwind's
utility classes allow you to control many aspects of your design, from
text alignment to spacing and colors.
You
said:
WRITE 10 ASSIGNMENTS
FROM ABOVE CONCEPT WITH STEP BY STEP SOLUTIONS with proper explanation
ChatGPT
said:
Here are
10 assignments based on the concepts covered in "Introduction to Tailwind
CSS," with step-by-step solutions and explanations:
Assignment
1: Create a Simple Centered Text Page
Task:
Create a webpage that centers the text "Welcome to Tailwind CSS!" on
the screen using Tailwind CSS.
Steps:
1.
Create an HTML file index.html.
2.
Add the Tailwind CDN in the <head> section.
3.
Use the flex,
justify-center, items-center, and h-screen classes to center
the text on the screen.
4.
Add an h1
element with the text "Welcome to Tailwind CSS!" and use text-4xl, font-bold, and text-blue-600 for styling.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Centered Text</title> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-100"> <div class="flex justify-center items-center h-screen"> <h1 class="text-4xl font-bold text-blue-600">Welcome to Tailwind CSS!</h1> </div></body></html>
Explanation:
- The
flexclass makes the container a flexbox. justify-centercenters the content horizontally.items-centercenters the content vertically.h-screensets the height of the container to the full height of the viewport.
Assignment
2: Add Background Color to the Page
Task:
Create a page with a light gray background and center the text "Tailwind
CSS Rocks!" with a blue font.
Steps:
1.
Add the Tailwind CDN to the HTML file.
2.
Use bg-gray-200
for the background color.
3.
Use text-center
to center the text.
4.
Use text-blue-500
to apply the blue text color.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Background</title> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-200"> <div class="flex justify-center items-center h-screen"> <h1 class="text-center text-blue-500 text-3xl font-semibold">Tailwind CSS Rocks!</h1> </div></body></html>
Explanation:
bg-gray-200gives a light gray background.text-centercenters the text horizontally.text-blue-500sets the text color to blue.
Assignment
3: Create a Button with Tailwind CSS
Task:
Create a button with the text "Click Me" and apply the following
styles:
- Background
color: blue.
- Text
color: white.
- Padding:
10px on all sides.
- Rounded
corners.
Steps:
1.
Create the HTML file and include
Tailwind CDN.
2.
Use bg-blue-500,
text-white, px-4, py-2, and rounded classes.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Button with Tailwind CSS</title> <script src="https://cdn.tailwindcss.com"></script></head><body> <div class="flex justify-center items-center h-screen"> <button class="bg-blue-500 text-white px-4 py-2 rounded">Click Me</button> </div></body></html>
Explanation:
bg-blue-500sets the background color to blue.text-whitechanges the text color to white.px-4andpy-2apply padding to the button.roundedmakes the button's corners rounded.
Assignment
4: Create a Card with Shadow and Padding
Task:
Create a card with the following:
- A
shadow effect.
- Padding
of 6 units.
- A
heading with the text "Tailwind Card" and text color blue.
Steps:
1.
Create the card structure.
2.
Apply shadow-lg,
p-6, bg-white, and text-blue-600.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Card with Tailwind CSS</title> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-200"> <div class="flex justify-center items-center h-screen"> <div class="shadow-lg p-6 bg-white rounded"> <h1 class="text-blue-600 text-xl font-bold">Tailwind Card</h1> </div> </div></body></html>
Explanation:
shadow-lgapplies a large shadow to the card.p-6applies padding inside the card.bg-whitegives the card a white background.roundedrounds the corners of the card.
Assignment
5: Create a Navigation Bar with Tailwind CSS
Task:
Create a simple navigation bar with the following:
- Links:
Home, About, and Contact.
- Background
color: blue.
- Text
color: white.
- Hover
effect: change text color to gray.
Steps:
1.
Create the navigation bar structure.
2.
Use bg-blue-500,
text-white, and hover:text-gray-400 for
styling.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Navigation Bar</title> <script src="https://cdn.tailwindcss.com"></script></head><body> <nav class="bg-blue-500 text-white"> <ul class="flex justify-center space-x-4 p-4"> <li><a href="#" class="hover:text-gray-400">Home</a></li> <li><a href="#" class="hover:text-gray-400">About</a></li> <li><a href="#" class="hover:text-gray-400">Contact</a></li> </ul> </nav></body></html>
Explanation:
bg-blue-500applies the background color to the navbar.text-whitechanges the text color to white.hover:text-gray-400adds a hover effect that changes the text color to gray when hovered.
Assignment
6: Create a Responsive Grid Layout
Task:
Create a responsive grid layout with 3 cards. On small screens, display them in
a single column, and on larger screens, display them in 3 columns.
Steps:
1.
Create the grid structure with grid and grid-cols-1.
2.
Use sm:grid-cols-3
to make it a 3-column layout on small screens.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Grid Layout</title> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-200"> <div class="grid grid-cols-1 sm:grid-cols-3 gap-4 p-6"> <div class="bg-white p-6 rounded shadow-lg">Card 1</div> <div class="bg-white p-6 rounded shadow-lg">Card 2</div> <div class="bg-white p-6 rounded shadow-lg">Card 3</div> </div></body></html>
Explanation:
gridcreates a grid container.grid-cols-1displays one column by default.sm:grid-cols-3applies a 3-column layout on screens 640px and above.gap-4adds space between the grid items.
Assignment
7: Apply Padding and Margin to Elements
Task:
Create a div with the following:
- 10px
padding on all sides.
- 20px
margin on the top and bottom, and 10px on the left and right.
Steps:
1.
Apply p-2
for padding.
2.
Apply mt-5,
mb-5, ml-2, and mr-2 for margin.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Padding and Margin</title> <script src="https://cdn.tailwindcss.com"></script></head><body> <div class="p-2 mt-5 mb-5 ml-2 mr-2 bg-gray-300"> This div has padding and margin applied. </div></body></html>
Explanation:
p-2applies padding of 10px (the base unit is 4px, so 2 means 8px).mt-5,mb-5,ml-2,mr-2apply the margins as specified.
Assignment
8: Create a Footer with Tailwind CSS
Task:
Create a footer with the following:
- Background
color: gray.
- Text
color: white.
- Center
the text.
Steps:
1.
Add the footer element.
2.
Apply bg-gray-800,
text-white, and text-center for styling.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Footer with Tailwind CSS</title> <script src="https://cdn.tailwindcss.com"></script></head><body> <footer class="bg-gray-800 text-white text-center p-4"> © 2024 Tailwind CSS Tutorial </footer></body></html>
Explanation:
bg-gray-800applies a dark gray background to the footer.text-whitechanges the text color to white.text-centercenters the text horizontally.
Assignment
9: Create a Responsive Image Gallery
Task:
Create a gallery of images that displays 3 images in a row on large screens and
a single image per row on small screens.
Steps:
1.
Use a grid layout.
2.
Use sm:grid-cols-1
for small screens and lg:grid-cols-3 for
larger screens.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Image Gallery</title> <script src="https://cdn.tailwindcss.com"></script></head><body> <div class="grid sm:grid-cols-1 lg:grid-cols-3 gap-4 p-6"> <img src="https://via.placeholder.com/300" alt="Image 1" class="w-full h-auto rounded shadow-lg"> <img src="https://via.placeholder.com/300" alt="Image 2" class="w-full h-auto rounded shadow-lg"> <img src="https://via.placeholder.com/300" alt="Image 3" class="w-full h-auto rounded shadow-lg"> </div></body></html>
Explanation:
gridcreates a grid layout.sm:grid-cols-1ensures that the grid will have 1 column on small screens.lg:grid-cols-3applies 3 columns on larger screens.w-fullmakes the image fill the width of the grid cell.
Assignment
10: Create a Form with Tailwind CSS
Task:
Create a simple login form with the following:
- Email
input with placeholder "Enter your email".
- Password
input with placeholder "Enter your password".
- Submit
button with the text "Login".
Steps:
1.
Create the form structure.
2.
Use bg-white,
p-6, rounded, shadow-lg, and w-full for styling.
Solution:
html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Form</title> <script src="https://cdn.tailwindcss.com"></script></head><body class="bg-gray-100"> <div class="flex justify-center items-center h-screen"> <form class="bg-white p-6 rounded shadow-lg w-96"> <h2 class="text-2xl font-semibold mb-4">Login</h2> <div class="mb-4"> <input type="email" placeholder="Enter your email" class="w-full p-3 border border-gray-300 rounded"> </div> <div class="mb-4"> <input type="password" placeholder="Enter your password" class="w-full p-3 border border-gray-300 rounded"> </div> <button type="submit" class="w-full bg-blue-500 text-white p-3 rounded hover:bg-blue-400">Login</button> </form> </div></body></html>
Explanation:
w-96sets the form width to 24rem.bg-white,p-6, androundedstyle the form container.w-fullmakes the inputs and button fill the available space.
These
assignments will help solidify your understanding of how to use Tailwind CSS to
create various layouts and elements for web pages.
You
said:
WRITE 50 no of MCQs
only FROM ABOVE CONCEPT with explanation
ChatGPT
said:
Here are
50 multiple-choice questions (MCQs) based on the Tailwind CSS concepts
mentioned above, along with explanations for each answer.
MCQs
on Tailwind CSS
1.
Which class is used to apply padding in Tailwind CSS?
o A)
p-4
o B)
m-4
o C)
w-4
o D)
h-4
Answer:
A) p-4
Explanation: p-4
applies padding on all sides of the element.
2.
How do you center text horizontally in Tailwind CSS?
o A)
center-text
o B)
text-center
o C)
justify-center
o D)
align-center
Answer:
B) text-center
Explanation: text-center
is used to center text horizontally.
3.
Which class in Tailwind CSS would be used to make a
background color gray?
o A)
bg-gray-500
o B)
bg-gray-800
o C)
bg-blue-500
o D)
bg-yellow-500
Answer:
B) bg-gray-800
Explanation: bg-gray-800
applies a dark gray background color.
4.
What does the w-full class in Tailwind CSS do?
o A)
Sets the width to 100px
o B)
Makes the width 50%
o C)
Sets the width to 100% of the parent container
o D)
Adds width to the element in percentage
Answer:
C) Sets the width to 100% of the parent container
Explanation: w-full
makes the width of the element span the full width of its parent container.
5.
How do you make an image responsive in Tailwind CSS?
o A)
responsive-img
o B)
img-responsive
o C)
w-full h-auto
o D)
responsive
Answer:
C) w-full h-auto
Explanation: w-full
h-auto ensures the image takes up the full width but adjusts its
height automatically.
6.
Which class is used to apply a shadow effect in Tailwind CSS?
o A)
shadow-md
o B)
bg-shadow
o C)
shadow-lg
o D)
box-shadow
Answer:
A) shadow-md
Explanation: shadow-md
applies a medium shadow effect to the element.
7.
To apply margin to the top of an element in Tailwind CSS,
which class is used?
o A)
mt-2
o B)
mb-2
o C)
ml-2
o D)
mr-2
Answer:
A) mt-2
Explanation: mt-2
adds margin to the top of the element.
8.
Which class in Tailwind CSS is used for setting rounded
corners?
o A)
rounded-lg
o B)
rounded-md
o C)
rounded
o D)
All of the above
Answer:
D) All of the above
Explanation: Tailwind provides multiple classes for rounding
corners, like rounded,
rounded-md,
and rounded-lg.
9.
How do you create a grid layout with Tailwind CSS?
o A)
grid-cols
o B)
grid
o C)
grid-rows
o D)
grid-layout
Answer:
B) grid
Explanation: grid
is used to define a grid layout in Tailwind CSS.
10.
What does the class lg:grid-cols-3 do?
- A)
Creates 3 columns on small screens
- B)
Creates 3 columns on large screens
- C)
Applies 3 column layout across all screens
- D)
Sets the grid layout to 3 columns on medium screens
Answer: B) Creates 3 columns on large
screens
Explanation: lg:grid-cols-3
applies a 3-column layout on large screens (screens above 1024px).
11.
Which of the following is the correct class for adding a
background color of blue in Tailwind CSS?
- A)
bg-blue-500 - B)
bg-blue - C)
bg-color-blue - D)
bg-500-blue
Answer: A) bg-blue-500
Explanation: bg-blue-500
sets the background color to blue with a medium shade.
12.
What is the correct class to apply padding to all sides in
Tailwind CSS?
- A)
p-0 - B)
p-4 - C)
m-4 - D)
padding-all
Answer: B) p-4
Explanation: p-4
applies padding of 1rem (16px) to all sides of an element.
13.
Which of the following classes is used to apply a hover
effect in Tailwind CSS?
- A)
hover:bg-blue-500 - B)
hover-effect - C)
hover:color-blue - D)
hover-transition
Answer: A) hover:bg-blue-500
Explanation: hover:bg-blue-500
changes the background color to blue when the element is hovered.
14.
How do you make a footer text white in Tailwind CSS?
- A)
text-white - B)
bg-white - C)
footer-white - D)
color-white
Answer: A) text-white
Explanation: text-white
sets the text color to white.
15.
Which class would make an element take up the entire width of
the parent container in Tailwind CSS?
- A)
w-full - B)
w-auto - C)
w-100 - D)
w-1/2
Answer: A) w-full
Explanation: w-full
makes the element span 100% of the parent container's width.
16.
Which class is used to center an element both vertically and
horizontally in Tailwind CSS?
- A)
flex justify-center items-center - B)
center-xy - C)
align-center justify-center - D)
align-middle justify-middle
Answer: A) flex
justify-center items-center
Explanation: flex
justify-center items-center is used to center an element in both
axes using Flexbox.
17.
What does sm:grid-cols-1 do in Tailwind CSS?
- A)
Creates 1 column layout on small screens
- B)
Creates 1 column layout on all screens
- C)
Creates a 1 column layout for tablets
- D)
Creates 1 column layout on small and medium screens
Answer: A) Creates 1 column layout on small
screens
Explanation: sm:grid-cols-1
applies a single-column grid layout on small screens (below 640px).
18.
How do you add a border in Tailwind CSS?
- A)
border - B)
borders - C)
border-color - D)
add-border
Answer: A) border
Explanation: The border
class applies a 1px solid border around an element.
19.
Which of the following classes will apply a large shadow
effect?
- A)
shadow-lg - B)
shadow-md - C)
shadow-sm - D)
shadow-xl
Answer: A) shadow-lg
Explanation: shadow-lg
applies a large shadow effect to an element.
20.
How do you create a background color of light gray in
Tailwind CSS?
- A)
bg-gray-300 - B)
bg-gray-light - C)
bg-light-gray - D)
bg-gray-100
Answer: A) bg-gray-300
Explanation: bg-gray-300
applies a light gray background color.
21.
Which of the following classes is used to add margin to the
bottom of an element?
- A)
mb-4 - B)
mt-4 - C)
ml-4 - D)
mr-4
Answer: A) mb-4
Explanation: mb-4
adds margin to the bottom of the element.
22.
What does h-auto do in Tailwind CSS?
- A)
Sets height to 100%
- B)
Sets height to auto (height adjusts based on content)
- C)
Sets the height to fixed
- D)
Sets height to 50%
Answer: B) Sets height to auto (height
adjusts based on content)
Explanation: h-auto
adjusts the height of an element based on its content.
23.
Which class adds a margin of 2 units to the right of an
element?
- A)
mr-2 - B)
ml-2 - C)
mt-2 - D)
mb-2
Answer: A) mr-2
Explanation: mr-2
applies a margin of 2 units (typically 0.5rem) to the right of the element.
24.
How do you apply a flex container in Tailwind CSS?
- A)
flex-container - B)
flex - C)
flex-box - D)
flex-wrapper
Answer: B) flex
Explanation: flex
is used to create a flex container.
25.
Which class will make an element's height equal to the
viewport height?
- A)
h-screen - B)
h-full - C)
h-100 - D)
vh-100
Answer: A) h-screen
Explanation: h-screen
sets the height of the element to be equal to the viewport height.
26.
Which class can you use to hide an element on small screens?
- A)
hidden sm:block - B)
sm:hidden - C)
block sm-none - D)
none sm-visible
Answer: B) sm:hidden
Explanation: sm:hidden
hides the element on small screens (below 640px) and above.
27.
What class in Tailwind CSS is used to apply padding to the
left side of an element?
- A)
pl-4 - B)
pt-4 - C)
pr-4 - D)
pb-4
Answer: A) pl-4
Explanation: pl-4
applies padding to the left side of the element.
28.
How can you apply a full-width background color to a header?
- A)
bg-full - B)
w-full bg-color - C)
bg-blue-500 - D)
header-full
Answer: C) bg-blue-500
Explanation: bg-blue-500
applies a blue background color to the header, and w-full can make it full
width.
29.
Which class is used to apply display as flex on a div in Tailwind CSS?
- A)
display-flex - B)
flex - C)
d-flex - D)
block-flex
Answer: B) flex
Explanation: flex
sets the display property of an element to flex.
30.
What does the justify-between class do in Tailwind CSS?
- A)
Centers the items
- B)
Justifies items to the right
- C)
Adds space between items
- D)
Applies equal margin to items
Answer: C) Adds space between items
Explanation: justify-between
spaces out flex items evenly with the first item aligned to the start and the
last item aligned to the end.
31.
Which class is used for vertical centering with flexbox in
Tailwind CSS?
- A)
items-center - B)
align-center - C)
justify-center - D)
center-vertical
Answer: A) items-center
Explanation: items-center
aligns flex items vertically at the center.
32.
What does text-lg class do in Tailwind CSS?
- A)
Makes the text large
- B)
Sets the font size to 16px
- C)
Makes the text bold
- D)
Sets the text color to large
Answer: A) Makes the text large
Explanation: text-lg
increases the text size to 1.125rem
(18px).
33.
What is the class for setting text to be bold in Tailwind
CSS?
- A)
text-bold - B)
font-bold - C)
bold - D)
font-heavy
Answer: B) font-bold
Explanation: font-bold
makes the text bold.
34.
How do you apply a light blue background color in Tailwind
CSS?
- A)
bg-light-blue - B)
bg-blue-100 - C)
bg-blue - D)
bg-blue-light
Answer: B) bg-blue-100
Explanation: bg-blue-100
applies a light blue background color.
35.
How do you set an element to be invisible but still occupy
space in Tailwind CSS?
- A)
opacity-0 - B)
hidden - C)
invisible - D)
display-none
Answer: C) invisible
Explanation: invisible
hides the element but it still takes up space in the layout.
36.
How do you set a border radius in Tailwind CSS?
- A)
radius-4 - B)
border-radius - C)
rounded-md - D)
border-radius-md
Answer: C) rounded-md
Explanation: rounded-md
sets a medium rounded corner for the element.
37.
What does flex-row-reverse do in Tailwind CSS?
- A)
Reverses the direction of flex items horizontally
- B)
Reverses the flex container's direction vertically
- C)
Makes flex items flow from bottom to top
- D)
Reverses the layout on mobile screens
Answer: A) Reverses the direction of flex
items horizontally
Explanation: flex-row-reverse
reverses the order of items in a row layout.
38.
Which class would be used to make text bold and uppercase in
Tailwind CSS?
- A)
font-bold uppercase - B)
bold uppercase - C)
uppercase-bold - D)
text-bold upper
Answer: A) font-bold
uppercase
Explanation: font-bold
makes the text bold, and uppercase
converts it to uppercase.
39.
What does the class space-x-4 do in Tailwind CSS?
- A)
Adds 4px of space between each child element horizontally
- B)
Adds 4px of space between all children elements
- C)
Sets space between elements vertically
- D)
Sets space for the entire container
Answer: A) Adds 4px of space between each
child element horizontally
Explanation: space-x-4
adds horizontal spacing between children elements in a flex or grid container.
40.
What does hover:text-gray-500 do in Tailwind CSS?
- A)
Changes the text color to gray on hover
- B)
Changes the text size to gray
- C)
Changes the background color to gray on hover
- D)
Changes the element's opacity on hover
Answer: A) Changes the text color to gray on
hover
Explanation: hover:text-gray-500
changes the text color to gray when the element is hovered.
41.
Which class is used for a bold font in Tailwind CSS?
- A)
text-bold - B)
font-weight-bold - C)
font-bold - D)
font-heavy
Answer: C) font-bold
Explanation: font-bold
applies a bold font style to the text.
42.
What does gap-4 do in Tailwind CSS?
- A)
Sets a gap of 4 units between flex or grid items
- B)
Sets a 4px margin
- C)
Sets a 4px padding around elements
- D)
Sets a 4px gap between the container and items
Answer: A) Sets a gap of 4 units between
flex or grid items
Explanation: gap-4
sets the space between flex or grid items.
43.
What class is used to apply rounded corners to only the
top-left corner of an element?
- A)
rounded-tl - B)
rounded-tl-md - C)
rounded-tl-lg - D)
rounded
Answer: A) rounded-tl
Explanation: rounded-tl
applies rounded corners to the top-left corner of the element.
44.
Which of the following Tailwind CSS classes is used to
control the visibility of an element?
- A)
display-none - B)
visibility-hidden - C)
invisible - D)
hidden
Answer: C) invisible
Explanation: invisible
makes the element invisible but still takes up space in the layout.
45.
Which class sets the width of an element to half of the
parent container?
- A)
w-1/2 - B)
w-50% - C)
width-50 - D)
half-width
Answer: A) w-1/2
Explanation: w-1/2
sets the width of an element to half of the parent container's width.
46.
Which class is used to create a container with a maximum
width in Tailwind CSS?
- A)
max-w-full - B)
max-width - C)
container - D)
w-max
Answer: C) container
Explanation: container
sets the maximum width of the element to the default container size.
47.
How do you create a responsive design for large screens in
Tailwind CSS?
- A)
lg:w-1/2 - B)
screen-lg - C)
lg-full - D)
lg-container
Answer: A) lg:w-1/2
Explanation: lg:w-1/2
makes the element take up half of the width on large screens.
48.
What does the truncate class do in Tailwind CSS?
- A)
Hides text that overflows and displays an ellipsis (
...) - B)
Shortens the text content
- C)
Removes all white spaces
- D)
Makes the text smaller
Answer: A) Hides text that overflows and
displays an ellipsis (...)
Explanation: truncate
applies text truncation with an ellipsis when the content overflows the
container.
49.
What does the class block do in Tailwind CSS?
- A)
Sets the display property to block
- B)
Hides the element
- C)
Adds a block of text
- D)
Applies a block background color
Answer: A) Sets the display property to
block
Explanation: block
changes the display property of an element to block.
50.
Which class in Tailwind CSS is used to make an image
responsive?
- A)
img-responsive - B)
img-fluid - C)
responsive-img - D)
w-full h-auto
Answer: D) w-full
h-auto
Explanation: w-full
h-auto makes the image responsive by setting its width to 100%
and height to auto.

No comments:
Post a Comment