Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Font-weight of Browse button

 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am trying to apply styles to my html browse button.I could change the font size of the "Browse" text on the Browse button but i want to make it BOLD ?
 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Can Any one Help

Thanks
Sindhu
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about the button created as part of the <input type="file"> element, there are limited options for styling. I do not believe that you will be able to affect the style of the button.

I have read about techniques where the file control is hidden and proxied by stylable elements, but I've never been able to get is working adequately in a cross-browser fashion. (Didn't try too hard though.) You might do a search and see if someone else has been successful.
 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I was able to work this with the help of css and javascript but i am not able to edit the path which is selected in the browse input field ..

My code is as follows :
html file :

<html>
<head>
<style type="text/css">
#mybrowse { font-weight: bold; }

div.fileinputs {
position: relative;
}

div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}

input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
</style>
</head>
<script type="text/javascript">
var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
if (!W3CDOM) return;
var fakeFileUpload = document.createElement('div');
fakeFileUpload.className = 'fakefile';
fakeFileUpload.appendChild(document.createElement('input'));
var x = document.getElementsByTagName('input');
alert(x.length);
for (var i=0;i<x.length;i++) {
if (x[i].type != 'file') continue;
if (x[i].parentNode.className != 'fileinputs') continue;
x[i].className = 'file hidden';
var clone = fakeFileUpload.cloneNode(true);
x[i].parentNode.appendChild(clone);
x[i].relatedElement = clone.getElementsByTagName('input')[0];
x[i].onchange = x[i].onmouseout = function () {
this.relatedElement.value = this.value;
}
}
}


function modify(){
alert("Modification Success");
}


></script>

<body>


<div class="fileinputs">
<input type="file" class="file" onchange="initFileUploads()" />
<div class="fakefile" >
<input />
<input type="button" value="Browse"id="mybrowse" /> </div>

</div>


</body>
</html>

.
Please suggest ideas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic