gpt4 book ai didi

html - 我如何将鼠标悬停在标签上传和提交按钮上以更改背景和文本

转载 作者:太空宇宙 更新时间:2023-11-04 09:53:05 25 4
gpt4 key购买 nike

我使用此代码是因为设计上传和提交按钮不使用 jquery 或 Javascript。我需要在悬停时更改上传和提交按钮的背景颜色和文本颜色。这是代码:JS Fiddle

* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.inputBtnSection {
display: inline-block;
vertical-align: top;
font-size: 0;
font-family: verdana;
}
.disableInputField {
display: inline-block;
vertical-align: top;
height: 27px;
margin: 0;
font-size: 14px;
padding: 0 3px;
}
.fileUpload {
position: relative;
overflow: hidden;
border: solid 1px gray;
display: inline-block;
vertical-align: top;
}
.fileUpload2 {
position: relative;
overflow: hidden;
border: solid 1px gray;
display: inline-block;
vertical-align: top;
}
.uploadBtn {
display: inline-block;
vertical-align: top;
background: rgba(0, 0, 0, 0.5);
font-size: 14px;
padding: 0 10px;
height: 25px;
line-height: 22px;
color: #fff;
}
.uploadBtn2 {
display: inline-block;
vertical-align: top;
background: rgba(0, 0, 0, 0.5);
font-size: 14px;
padding: 0 10px;
height: 25px;
line-height: 22px;
color: #fff;
}
.fileUpload input.upload {
top: 0;
position: absolute;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.fileUpload2 input.submit {
top: 0;
position: absolute;
right: 0;
margin: 0;
padding: 0;
font-size: 20px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
<div class="formulir">
<form action="php/upload.php" method="post" enctype="multipart/form-data">
<div class="inputBtnSection">

<input id="uploadFile" class="disableInputField" placeholder="Choose File" disabled="disabled" />

<label class="fileUpload">
<input id="uploadBtn" type="file" class="upload" name="fileToUpload" />
<span class="uploadBtn">Browse File</span>
</label>
</div>

<label class="fileUpload2">
<input id="uploadtn2" type="submit" value="Upload Image" name="submit" class="submit">
<span class="uploadBtn2">upload</span>
</label>

</form>
</div>

最佳答案

这是 Fiddle

刚刚向元素添加了 :hover 类。

CSS:

.fileUpload:hover {
background-color: rgba(0, 0, 256, 0.5);
transition: all 0.25s;
}

.fileUpload2:hover {
background-color: green;
transition: all 0.25s;
}

关于html - 我如何将鼠标悬停在标签上传和提交按钮上以更改背景和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38952664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com