html+css实现赛博朋克风格按钮
Sure, here is an example of how to create a cyberpunk-style button using HTML and CSS:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cyberpunk Button</title>
<style>
/* Basic styles */
body {
margin: 0;
padding: 0;
font-family: monospace;
background-color: #333;
color: #fff;
}
/* Button container */
.button-container {
position: relative;
display: inline-block;
padding: 10px 20px;
border: 2px solid #fff;
border-radius: 10px;
cursor: pointer;
transition: background-color 0.3s ease;
}
/* Button text */
.button-text {
font-size: 16px;
text-transform: uppercase;
letter-spacing:2px;
transition: color 0.3s ease;
}
/* Button hover effect */
.button-container:hover {
background-color: #007bff;
}
.button-container:hover .button-text {
color: #fff;
}
/* Optional glow effect */
.button-container::before,
.button-container::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
border-radius: 50%;
opacity: 0;
transition: opacity 0.3s ease;
}
.button-container::before {
background-color: #007bff;
}
.button-container:hover::before,
.button-container:hover::after {
opacity: 0.2;
}
</style>
</head>
<body>
<div class="button-container">
<span class="button-text">Click Me</span>
</div>
</body>
</html>
Explanation:
HTML Structure:
div
container with the class button-container
to hold the button content.span
element with the class button-text
contains the button text.CSS Styles:
.button-container
is styled with padding, border, border-radius, cursor, and transition for hover effects..button-text
is styled with font size, text transform, letter spacing, and transition for hover effects.::before
and ::after
pseudo-elements with absolute positioning, border-radius, opacity, and transition. These elements create a subtle glow around the button on hover.