Home > Article > Web Front-end > CSS (Cascading Style Sheets) is essential for designing the front end of websites
Let's explore some common CSS examples that you can use to enhance your web projects:
Basic Styling:
.my-element { background-color: #f0f0f0; }
Change text color:
.my-text { color: #333; }
Borders:
.my-box { border: 2px solid #ddd; }
Margins and Padding:
.my-box { margin: 10px 20px; }
Set padding for an element:
.my-content { padding: 15px; }
Backgrounds:
body { background-color: #f9f9f9; }
Use an image as the background:
.hero-section { background-image: url('path/to/image.jpg'); background-size: cover; }
Responsive Design:
@media screen and (max-width: 768px) { .my-element { font-size: 14px; } }
Remember to replace the class names (e.g., .my-element) with your actual HTML elements.
The above is the detailed content of CSS (Cascading Style Sheets) is essential for designing the front end of websites. For more information, please follow other related articles on the PHP Chinese website!