我正在為我的網站上傳文件,當我嘗試將 id 為“cool-border”的 div 更改為表單元素以便能夠上傳文件時,我的代碼不再有效。當我選擇一個文件時,文件名不再顯示在文件文本范圍中。我刪除了一些用于拖放過程的代碼以整理混亂,但是是的,我很困惑抱歉,縮放比例不穩定,哈哈,我還沒有讓它響應body { margin: 0; padding: 0; box-sizing: border-box; font-family: Arial, Helvetica, sans-serif; background-color: black;}#dropContainer { border-radius: 1em; color: #effffb; background-color: #6cd89d; font-size: large; font-weight: bold; margin: 20px; padding: 1em; text-align: center; line-height: 2em; max-width: 50vh;}#fakeButton { background-color: #a5a5a5; border: none; border-radius: 5px; padding: 5px; cursor: pointer; color: #effffb;}#fakeButton:hover{ background-color: #5c5c5c;}span { font-size: small; font-weight: normal;}#cool-border { background-image: linear-gradient(90deg, #effffb 50%, transparent 50%), linear-gradient(90deg, #effffb 50%, transparent 50%), linear-gradient(0deg, #effffb 50%, transparent 50%), linear-gradient(0deg, #effffb 50%, transparent 50%); background-repeat: repeat-x, repeat-x, repeat-y, repeat-y; background-size: 15px 2px, 15px 2px, 2px 15px, 2px 15px; background-position: left top, right bottom, left bottom, right top; animation: border-dance 1s infinite linear; border-radius: 5px; padding: 1em;}@keyframes border-dance { 0% { background-position: left top, right bottom, left bottom, right top; } 100% { background-position: left 15px top, right 15px bottom , left bottom 15px , right top 15px; } }}<!DOCTYPE html><html><head> <link href="style.css" rel="stylesheet"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>File Upload</title></head><body>
1 回答

楊__羊羊
TA貢獻1943條經驗 獲得超7個贊
您的按鈕需要具有 type="button" 屬性,如下所示:
<button?type="button"?id="fakeButton">Select?a?file</button>
否則,它充當提交按鈕,如果沒有指定操作,它基本上會刷新瀏覽器。
type:?按鈕的默認行為。可能的值有: 該按鈕將表單數據提交到服務器。如果未為與表單關聯的按鈕指定該屬性,或者該屬性為空值或無效值,則這是默認值。
- 1 回答
- 0 關注
- 97 瀏覽
添加回答
舉報
0/150
提交
取消