Here's a table with advanced CSS commands, organized systematically, along with example code for each command:
Command | Description | Example Code |
---|---|---|
1. CSS Transitions | Create smooth transitions for element property changes. |
css/* Apply a transition to 'color' property */
transition: color 0.5s ease;
| 2. CSS Animations | Design complex animations for enhanced user experience. |
css/* Animate an element's size and color */
@keyframes slide {
0% { transform: scale(1);
background: blue; }
100% { transform: scale(1.5);
background: red; }
}
/* Apply the animation */
animation: slide 3s infinite;
| 3. CSS Pseudo-classes | Style elements based on their state or position. |
css/* Style a link on hover */
a:hover
{
text-decoration: underline;
}
| 4. CSS Pseudo-elements | Target specific parts of an element for styling. |
css/* Style the first line of a paragraph */
p::first-line
{
font-weight: bold;
}
| 5. CSS Variables (Custom Properties) | Define and use custom CSS variables for reusability. |
css/* Define a variable */
:root
{
--main-color: #3498db;
}
/* Use the variable */
button
{
background-color: var(--main-color);
}
| 6. CSS Media Queries | Create responsive designs for various screen sizes. |
css/* Adjust layout for smaller screens */
@media (max-width: 600px)
{
.container {
flex-direction: column;
}
}
| 7. CSS Flexbox and Grid | Implement modern layout systems for complex designs. |
css/* Create a flexible layout using Flexbox */
.container
{
display: flex;
justify-content: space-between;
}
/* Design a grid layout */
.grid
{
display: grid;
grid-template-columns: repeat(3, 1fr);
}
| 8. CSS Transforms | Apply 2D and 3D transformations to elements. |
css/* Rotate an element 45 degrees */
transform: rotate(45deg);
/* Apply a 3D transformation */
transform: perspective(500px)
rotateX(45deg);
These advanced CSS commands will help you enhance your web design skills and create more dynamic and responsive websites. Experiment with them to see the powerful effects they can achieve.