要自定义 PHP 按钮样式,您需要使用 HTML、CSS 和(可选的)JavaScript。以下是一个简单的示例,说明如何创建一个自定义按钮并使用 PHP 输出该按钮。
创建一个名为styles.css 的 CSS 文件,用于存放您的自定义样式:.custom-button { background-color: #4CAF50; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; border-radius: 12px;}.custom-button:hover { background-color: #45a049;}在您的 PHP 文件中,使用 HTML 和内联 CSS 输出按钮,并为其添加一个类,以便在 CSS 文件中对其进行样式设置:<?php// your_php_code_here?><!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Custom PHP Button</title> <link rel="stylesheet" href="styles.css"></head><body> <button class="custom-button" onclick="your_javascript_function()">Click me!</button> <!-- your_html_code_here --> <script> // your_javascript_code_here </script></body></html>现在,当您加载 PHP 文件时,它将输出一个带有自定义样式的按钮。您可以根据需要修改 styles.css 文件中的样式,以创建您想要的按钮外观。