I have an html that uses a file input field <input name="fileinput" type="field">
The apperance is overlayed with own text by using the label tag. Now I want to use an svg image instead of an ordinary text
<input type='file' name="fileinput" id="fileinput" style="display:none">
<label for="fileinput" style="border: 1px solid red;">
<svg id="imp" width="25px" height="25px" viewBox="0 0 59 30" style="margin-left: calc(50% - 0.5em)">
<g transform="scale(0.03125 0.03125)">
<path d="M576 256l-128-128h-448v832h1024v-704h-448zM512 480l224 224h-160v256h-128v-256h-160l224-224z"></path>
</g>
</svg>
</label><br>
<button type="button" id="export" onClick="export()">
<svg alt="Export" width="25px" height="25px" viewBox="0 0 59 30" style="margin-left: calc(50% - 0.5em)"><g transform="scale(0.03125 0.03125)"><path d="M576 256l-128-128h-448v832h1024v-704h-448zM512 864l-224-224h160v-256h128v256h160l-224 224z"></path></g></svg>
</button>
I’m unable to style the label so it looks like a button. Is there a way to achive this goal? May I have to convert the image to a different format?
Thanks in advanced
2
Answers
Give the
label
adisplay
property of, say,inline-block
and add whatever additional styles you might need.Best long term plan is to learn SVG. You are now stacking SVG transforms upon CSS padding alignments. Building a tower of a Babel.
Garbage in is garbage out
Learn tools like:
For individual
path d=""
For whole SVGs
Only after your SVG is optimized can you use it optimal in your HTML code
Alignment issues left in for educational puposus
This code also available in https://jsfiddle.net/WebComponents/gypqetks/
Once the SVG is correct you can adjust the viewBox="
x y width height
".And the startposition of the
<path d="M x y "
pathsLearning time investment now, pays of in your SVG future