写一个好看的button样式
时间: 2023-09-14 07:09:26 浏览: 63
以下是一个简单的好看的button样式,你可以根据需要进行修改和调整:
HTML代码:
```html
<button class="my-button">Click me!</button>
```
CSS代码:
```css
.my-button {
background-color: #4CAF50; /* 设置背景颜色 */
border: none; /* 去掉边框 */
color: white; /* 设置文字颜色 */
padding: 10px 20px; /* 设置内边距 */
text-align: center; /* 文字居中 */
text-decoration: none; /* 去掉下划线 */
display: inline-block; /* 设置为行内块级元素 */
font-size: 16px; /* 设置字体大小 */
border-radius: 5px; /* 圆角 */
transition-duration: 0.4s; /* 过渡动画时间 */
cursor: pointer; /* 设置为手型光标 */
}
.my-button:hover {
background-color: #3e8e41; /* 鼠标悬停时的背景颜色 */
}
```
相关问题
利用html写一个好看的页面
好的,下面是一个简单的HTML页面示例,包含一些基本的HTML标签和CSS样式,可以让页面看起来更加好看:
```html
<!DOCTYPE html>
<html>
<head>
<title>我的HTML页面</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
h1 {
color: #333;
text-align: center;
margin-top: 50px;
}
p {
font-size: 18px;
line-height: 1.5;
padding: 10px;
background-color: #fff;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
border-radius: 5px;
margin-top: 20px;
margin-bottom: 20px;
}
img {
max-width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #4CAF50;
color: #fff;
border-radius: 5px;
text-decoration: none;
margin-top: 20px;
}
.button:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<header>
<h1>欢迎来到我的页面</h1>
</header>
<main>
<p>这是一个简单的HTML页面示例,包含一些基本的HTML标签和CSS样式,可以让页面看起来更加好看。</p>
<img src="https://via.placeholder.com/500x300" alt="示例图片">
<a href="#" class="button">了解更多</a>
</main>
<footer>
<p>版权所有 © 2021</p>
</footer>
</body>
</html>
```
这个页面包含了一个标题、一段文字、一张图片和一个按钮。CSS样式使得页面看起来更加美观,比如背景颜色、字体、边框和阴影的设置,以及按钮的样式和悬停效果的设置。
您可以根据自己的需求,自定义更多的HTML标签和CSS样式,来实现一个更加好看的页面。
写一个好看的html登录页面出来
以下是一个简单的HTML登录页面的示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, Helvetica, sans-serif;
}
.container {
margin: auto;
max-width: 400px;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0px 0px 10px #ccc;
text-align: center;
}
h1 {
color: #333;
text-align: center;
font-size: 28px;
margin-bottom: 20px;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: #fff;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
font-size: 18px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h1>Login</h1>
<form>
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<button type="submit">Login</button>
</form>
</div>
</body>
</html>
```
这个页面使用了简单的CSS样式来使页面看起来更漂亮,其中包括:
- 设置了页面背景颜色和字体
- 创建了一个最大宽度为400px的容器,使表单居中显示
- 设置了标题样式
- 创建了文本框和按钮样式,并将其居中对齐
你可以根据自己的需求修改这个示例,添加更多的字段和样式。