【带给你不一样的思路】纯 CSS + HTML 实现几个好看的案例
以下是几个使用纯 CSS 和 HTML 实现的简单示例,展示了不同的视觉效果和布局技巧。
- 简单的三栏布局:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple 3-Column Layout</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
}
.container {
display: flex;
flex-wrap: wrap;
}
.column {
flex: 1;
margin: 10px;
padding: 15px;
background-color: #f2f2f2;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="container">
<div class="column">Column 1</div>
<div class="column">Column 2</div>
<div class="column">Column 3</div>
</div>
</body>
</html>
- 带有渐变背景的圆形按钮:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Circle Button with Gradient</title>
<style>
.button {
width: 100px;
height: 100px;
border-radius: 50%;
background: linear-gradient(to right, #30cfd0 0%, #330867 100%);
display: flex;
align-items: center;
justify-content: center;
color: white;
cursor: pointer;
transition: background 0.5s ease;
}
.button:hover {
background: linear-gradient(to right, #330867 0%, #30cfd0 100%);
}
</style>
</head>
<body>
<div class="button">Button</div>
</body>
</html>
- 创建一个简单的下拉菜单:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Dropdown Menu</title>
<style>
ul {
list-style: none;
padding: 0;
margin: 0;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1;}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<ul>
<li class="dropdown">
<a href="#">Dropdow
评论已关闭