我正在為我的網(wǎng)站上傳文件,當(dāng)我嘗試將 id 為“cool-border”的 div 更改為表單元素以便能夠上傳文件時,我的代碼不再有效。當(dāng)我選擇一個文件時,文件名不再顯示在文件文本范圍中。我刪除了一些用于拖放過程的代碼以整理混亂,但是是的,我很困惑抱歉,縮放比例不穩(wěn)定,哈哈,我還沒有讓它響應(yīng)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貢獻(xiàn)1943條經(jīng)驗(yàn) 獲得超7個贊
您的按鈕需要具有 type="button" 屬性,如下所示:
<button?type="button"?id="fakeButton">Select?a?file</button>
否則,它充當(dāng)提交按鈕,如果沒有指定操作,它基本上會刷新瀏覽器。
type:?按鈕的默認(rèn)行為??赡艿闹涤校?該按鈕將表單數(shù)據(jù)提交到服務(wù)器。如果未為與表單關(guān)聯(lián)的按鈕指定該屬性,或者該屬性為空值或無效值,則這是默認(rèn)值。
- 1 回答
- 0 關(guān)注
- 96 瀏覽
添加回答
舉報
0/150
提交
取消