2014-09-29 48 views
0

我在Firefox和IE中遇到文件按钮样式问题。它在Chrome中正常工作。IE和Firefox中的文件按钮问题

File button and normal button in Firefox and IE

CSS

.custom-file-input { background-color:#44c767;-moz-border-radius:28px;-webkit-border-radius:28px;border-radius:28px; border:1px solid #18ab29;display:inline-block;cursor:pointer; 
     color:#ffffff;font-family:arial;font-size:17px;padding:16px 31px;text-decoration:none;text-shadow:0px 1px 0px #2f6627; } 
    .custom-file-input:hover { background-color:#5cbf2a; } 
    .custom-file-input:active { position:relative; top:1px; } 

    .custom-file-input::-webkit-file-upload-button { visibility: hidden; } 
    .custom-file-input::before { content: 'Upload';outline: none; white-space: nowrap;-webkit-user-select: none;cursor: pointer;font-size: 11pt; } 
    input[type="file"] { width: 11%; height:55px; float:left; } 
    input[type="button"] { overflow:hidden; } 

HTML

 <input type="file" id="imgModalBanner" class="custom-file-input" value="Upload" onchange="readURL(this)" /> 
    <input type="button" id="btnFinish" class="custom-file-input" value="Finish" /> 
+0

请摆弄它。谢谢\ – Tushar 2014-09-29 06:34:13

+0

我已经尝试了几个小时。但是,没有运气。 – KiranD 2014-09-29 06:36:08

+0

Atleast为其他人拨弄它 – Tushar 2014-09-29 06:36:45

回答

0

我得到了解决。

HTML

<label class="custom-file-input"> 
Upload 
<span> 
<input type="file" id="myfile" name="myfile" onchange="readURL(this)" /> 
</span> 
</label> 
<input type="button" id="btnFinish" class="custom-file-input" value="Finish" /> 

CSS

.custom-file-input { 
background-color:#44c767; 
-moz-border-radius:28px; 
-webkit-border-radius:28px; 
border-radius:28px; 
border:1px solid #18ab29; 
display:inline-block; 
cursor:pointer; 
color:#ffffff; 
font-family:arial; 
font-size:17px; 
padding:16px 31px; 
text-decoration:none; 
text-shadow:0px 1px 0px #2f6627; 
} 
.custom-file-input:hover { 
    background-color:#5cbf2a; 
} 
.custom-file-input:active { 
position:relative; 
top:1px; 
} 
.custom-file-input::-webkit-file-upload-button { 
visibility: hidden; 
} 
.custom-file-input::before { 
/*content: 'Upload';*/ 
outline: none; 
white-space: nowrap; 
-webkit-user-select: none; 
cursor: pointer; 
font-size: 11pt; 
} 
input[type="file"] { 
width: 11%; 
height:55px; 
float:left; 
display:block; 
} 
input[type="button"] { 
overflow:hidden; 
} 
input[type="file"]{ 
z-index: 999; 
line-height: 0; 
font-size: 50px; 
position: absolute; 
opacity: 0; 
filter: alpha(opacity = 0);-ms-filter: "alpha(opacity=0)"; 
cursor: pointer; 
_cursor: hand; 
margin: 0; 
padding:0; 
left:0; 
} 

工作小提琴是jsfiddle.net/8g6rw492

+0

如果你想提供一个小提琴的答案,你必须添加一些代码 – dippas 2014-10-01 00:27:09

+0

更新它。谢谢 :) – KiranD 2014-10-01 00:34:39

0

而不是input尝试button

<input type="file" id="imgModalBanner" class="custom-file-input" value="Upload" onchange="readURL(this)" /> 

更改为

<button type="file" id="imgModalBanner" class="custom-file-input" value="Upload" onchange="readURL(this)" /> 

这里工作小提琴,它工作在Mozilla和IE9享受!

http://jsfiddle.net/jnzy8gs7/4/

+0

有一个小问题在这里。我如何处理文件控制?完成按钮不能有上传文本。 – KiranD 2014-09-29 06:53:06

+1

我不认为'button type =“file”'存在。你的小提琴没有打开上传对话框。 – Dmitry 2014-09-29 06:55:15

+0

这个问题已经在这里回答了 http://stackoverflow.com/questions/10643270/file-upload-button-and-odd-text-cursor-behavior-in-ie – 2014-09-29 07:00:52

0

你可以试试这个也

<label class="add-photo-btn"> 
     upload 
     <span> 
      <input type="file" id="myfile" name="myfile" /> 
     </span> 
</label> 

input[type="file"]{ 
    z-index: 999; 
    line-height: 0; 
    font-size: 50px; 
    position: absolute; 
    opacity: 0; 
    filter: alpha(opacity = 0);-ms-filter: "alpha(opacity=0)"; 
    cursor: pointer; 
    _cursor: hand; 
    margin: 0; 
    padding:0; 
    left:0; 
} 

.add-photo-btn{ 
    position:relative; 
    overflow:hidden; 
    cursor:pointer; 
    text-align:center; 
    background-color:#83b81a; 
    color:#fff;display:block; 
    width:197px; 
    height:31px; 
    font-size:18px; 
    line-height:30px; 
    float:left; 
} 

工作拨弄

http://jsfiddle.net/JJRrc/1324/