Wie man erstellt: Download-Button
Lernen Sie, wie man mit CSS das Stil des Download-Buttons einstellt.
Automatische Breite:
Vollbreite:
Wie man einen Download-Button erstellt
Erster Schritt - HTML hinzufügen:
Fügen Sie eine Symbolbibliothek hinzu, z.B. Font Awesome, und fügen Sie das Symbol dem HTML-Button hinzu:
<!-- 添加图标库 --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- 自动宽度 --> <button class="btn"><i class="fa fa-download"></i> Download</button> <!-- 全宽 --> <button class="btn" style="width:100%"><i class="fa fa-download"></i> Download</button>
Zweiter Schritt - CSS hinzufügen:
/* 设置按钮样式 */ .btn { background-color: DodgerBlue; border: none; color: white; padding: 12px 30px; cursor: pointer; font-size: 20px; } /* 鼠标悬停时背景变暗 */ .btn:hover { background-color: RoyalBlue; }
相关页面
教程:图标教程
教程:CSS 按钮