Let's build the above challenge with CSS variables.
Setup
Let's start with a semantic blockquote element
Card Info
- Style the container in center of the screen with responsive width
box-sizingto includepaddingin itswidth- Left side slightly indented
- Creating nice box for quote card
Card Content
- Para content
- Cite author name
CSS Variable
- Adding
CSS variablefor colors & shadow with fallback CSS Variablemakes it easier to create variants with different themesCSS Variablegets inherited and can be easily overridden
Quote wording
Makes the quote wordings larger and limits its width
Cite wording
Makes the cite wordings slimer & a little transparent
Before quote
- Choosing
“as a decoration character - Makes it a nicer & larger font
- Color blend with background
Before quote positioning
positionthe quote theabsoluteto break the normal flowpositionthe cardrelativeso that quote starts from the card- Adjust
positionslightly to the top-left
After quote positioning
- Choosing
”as a decoration character to close the quote - Same as before quote but larger and positioned to the bottom-right
Common CSS
- Take common
CSS& comma separate it Distributethe difference to:before&:after(position&size)
Responsiveness ✨
Makes the quote smaller on phone screens
Blue card
Make another quote card to customize it later
Add blue-card class to customize it
Blue variant 💙
Use CSS variable to create a blue variant, the variable will override the value that we have used in the .quote-card
Red card
Make another quote card with red-card to theme it red
Red variant ❤️
Use CSS variable to create a red variant, the variable will override the value that we have used in the .quote-card
Yellow card
Make another quote card with yellow-card to theme it yellow
Yellow variant 💛
Use CSS variable to create a yellow variant, the variable will override the value that we have used in the .quote-card
Setup
Let's start with a semantic blockquote element
Card Info
- Style the container in center of the screen with responsive width
box-sizingto includepaddingin itswidth- Left side slightly indented
- Creating nice box for quote card
Card Content
- Para content
- Cite author name
CSS Variable
- Adding
CSS variablefor colors & shadow with fallback CSS Variablemakes it easier to create variants with different themesCSS Variablegets inherited and can be easily overridden
Quote wording
Makes the quote wordings larger and limits its width
Cite wording
Makes the cite wordings slimer & a little transparent
Before quote
- Choosing
“as a decoration character - Makes it a nicer & larger font
- Color blend with background
Before quote positioning
positionthe quote theabsoluteto break the normal flowpositionthe cardrelativeso that quote starts from the card- Adjust
positionslightly to the top-left
After quote positioning
- Choosing
”as a decoration character to close the quote - Same as before quote but larger and positioned to the bottom-right
Common CSS
- Take common
CSS& comma separate it Distributethe difference to:before&:after(position&size)
Responsiveness ✨
Makes the quote smaller on phone screens
Blue card
Make another quote card to customize it later
Add blue-card class to customize it
Blue variant 💙
Use CSS variable to create a blue variant, the variable will override the value that we have used in the .quote-card
Red card
Make another quote card with red-card to theme it red
Red variant ❤️
Use CSS variable to create a red variant, the variable will override the value that we have used in the .quote-card
Yellow card
Make another quote card with yellow-card to theme it yellow
Yellow variant 💛
Use CSS variable to create a yellow variant, the variable will override the value that we have used in the .quote-card
