Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change text-decoration to underline when hovering the a element, if the a element is below another element with position absolute?

My goal is to create <input type=file> that is hidden. Then, use the a element to output Or choose your files.

The problem is:

  1. When I hover over the text, the text won’t be underlined.
  2. The solution was, position: relative. Then, the text will be underlined when I hover over the text. However, when I click the text, it will not open the choose file window. Clicking outside the text will open the choose file window.
input[type=file] {
  opacity: 0;
  position: absolute;
}

a {
  text-decoration: none;
  position: relative;
}

a:hover {
  text-decoration: underline;
}
<input type=file>
Or
<a href="#">choose your files</a>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this instead

#e-statement {
  display: none;
}

label:hover {
  text-decoration: underline;
  cursor: pointer;
}

label {
  color: blue;
}
Or <label for='e-statement'><input id='e-statement' type="file" name="e-statement">
  choose your files</label>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading