Examples in CSS
? Examples in CSS
Here are some common CSS examples to illustrate how different CSS features work in practice.
1. Basic Styling Example
body { font-family: Arial, sans-serif; background-color: #f0f0f0; color: #333; margin: 20px;}h1 { color: #007bff; text-align: center;}2. Centering a Div (Flexbox)
.container { display: flex; justify-content: center; /* horizontal center */ align-items: center; /* vertical center */ height: 200px; background-color: #ddd;}3. Responsive Image
img { max-width: 100%; height: auto; display: block;}4. Button Styling
button { background-color: #28a745; border: none; color: white; padding: 10px 16px; cursor: pointer; border-radius: 4px; font-size: 16px;}button:hover { background-color: #218838;}5. CSS Grid Layout
.grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;}.grid-item { background-color: #3498db; color: white; padding: 20px; text-align: center;}6. Text Shadow Example
h2 { text-shadow: 2px 2px 4px rgba(0,0,0,0.3);}If you want examples on any specific CSS topic like animations, transitions, forms, or layouts — just ask!