满意答案

hxxq0228
2013.05.27

采纳率:45% 等级:8
已帮助:362人
定义html 中input file的样式body {
font-size: 14px;
}
input {
vertical-align: middle;
margin: 0;
padding: 0
}
.file_style {
position: relative;
width: 340px
}
.text_style {
height: 22px;
border: 1px solid #cdcdcd;
width: 180px;
}
.button_style {
background-color: #FFF;
border: 1px solid #CDCDCD;
height: 24px;
width: 70px;
}
.file_item {
position: absolute;
top: 0;
right: 80px;
height: 24px;
filter: alpha(opacity : 0);
opacity: 0;
width: 260px
}
type="button" class="button_style" value="浏览..." />
name="fileField" class="file_item" id="fileField" size="28"
onchange="document.getElementById('textfield').value=this.value" />
00分享举报
这篇博客详细介绍了如何使用CSS来定制HTML中的文件输入(input[type=file])元素的样式,包括创建一个包含文本框和按钮的复合样式。通过定位和透明度设置,实现了将实际的文件选择按钮隐藏,同时提供一个自定义的‘浏览...’按钮,当用户点击该按钮时,可以触发文件选择对话框。
918

被折叠的 条评论
为什么被折叠?



