-3

I would like to put inputs label on border cross section and would like to hide borders under label like this enter image description here I did this by simply making label background white but it obviously doesn't work if I place it inside grey div any other solution for this?

Also I'm using quasar inputs so I'm limited to css only solutions

Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79
Trekstler
  • 71
  • 9
  • 1
    Does this answer your question? [Placing – Nebojsa Nebojsa Jan 20 '22 at 12:43
  • 1
    Give us some code, what did you tried so far? – Nebojsa Nebojsa Jan 20 '22 at 12:44
  • 1
    @Trekstler I recommend positioning the label with position. This gives you more flexibility. https://stackoverflow.com/a/70786590/14807111 – Maik Lowrey Jan 20 '22 at 12:59

2 Answers2

4

Use fieldset

textarea {
  width: 100%;
  border: none;
}
<form>
  <fieldset>
    <legend>Your heading</legend>
    <textarea></textarea>
  </fieldset>
</form>
Nitheesh
  • 19,238
  • 3
  • 22
  • 49
1

You can use position absolute for the label and the use top and left for position your label. Why using position? Then you have more flexibilty. Maybe you can push the label to the right and so on.

* {
  font-family: arial;
}

/** float container */
.float-container {
  border: solid 1px #ccc;
  box-sizing: border-box;
  margin-bottom: 8px;
  padding: 0 8px;
  position: relative;
  width: 300px;
} 
input {  
    border: none;
    font-size: 16px;
    outline: 0;
    padding: 16px 0 10px;    
    width: 100%;
  }

  label {
    font-size: 12px;
    position: absolute;
    top: -6px;
    left: 10px;
    background: white;
  }
  
<div id="floatContainer1" class="float-container ">
  <label for="floatField1 ">Label 1</label>
  <input type="text" id="floatField1" data-placeholder="Placeholder 1">
</div>
Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79