Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display label inside select

I couldn't find any relevant information and not even sure it's feasible in HTML, but I would like to display a Label line above the value in a select field, like the "EXP MONTH/YEAR" in the following image:

Select Labels

Is that doable? I've been searching for a way to implement it for a few days days to no avail. Thanks!

like image 984
pat_brat Avatar asked May 30 '17 15:05

pat_brat


People also ask

How do I view labels that were not placed?

You can view the labels that were not placed by clicking the View Unplaced Labels button located on the Labeling toolbar. Unplaced labels appear in red by default, although you can change the color of unplaced labels on the Labeling Options dialog box accessed from the Labeling menu of the Labeling toolbar.

What is the labeling feature?

See the latest documentation. Labeling is an easy way to add descriptive text to features on your map. Labels are dynamically placed, and label text strings are based on feature attributes. You can turn labels on or off by checking the box next to each layer and label class to label on the Label Manager.

How do I display the label of the answer option?

In order to display the label of the answer option rather than the answer option itself, one has to first use the choice-label () function in a calculate field and then refer to this calculate field instead. The choice-label () function lets you pull the label associated with a particular answer value and store that label as a string.

How do I control the labeling process in a map?

From here, you can control the labeling process and open the Label Manager dialog box, which lets you view and change labeling properties for all the labels in your map. By clicking the Summary button on the Label Manager dialog box, you can access the Label class summary dialog box.


1 Answers

I may be a little bit late, but: You do not need anything special, it's simply formating. Put label on top of form, wrap both label and select in a div, then adjust background colors and borders. See the example:

.select-wrap 
{
  border: 1px solid #777;
  border-radius: 4px;
  margin-bottom: 10px;
  padding: 0 5px 5px;
  width:200px;
  background-color:#ebebeb;
}

.select-wrap label
{
  font-size:10px;
  text-transform: uppercase;
  color: #777;
  padding: 2px 8px 0;
}

select
{
  background-color: #ebebeb;
  border:0px;
}
<div class="select-wrap">
  <label>Color</label>
  <select name="color" style="width: 100%;">
    <option value="">---</option>
    <option value="yellow">Yellow</option>
    <option value="red">Red</option>
    <option value="green">Green</option>
  </select>
</div>

UPDATE

I somehow remembered that I have this post. As I have improved it for personal usage, and this is version is better (you can click anywhere inside select - it will trigger dropdown, while on previous version you couln't) I thought I should share an update I have made to my code and used since.

.select-wrap {
  border: 1px solid #777;
  border-radius: 4px;
  padding: 0 5px;
  width:200px;
  background-color:#fff;
  position:relative;
}
.select-wrap label{
  font-size:8px;
  text-transform: uppercase;
  color: #777;
  padding: 0 8px;  
  position: absolute;
  top:6px;
}

select{
  background-color: #fff;
  border:0px;
  height:50px;
  font-size: 16px;
}
<div class="select-wrap">
  <label>Color</label>
  <select name="color" style="width: 100%;">
    <option value="">---</option>
    <option value="yellow">Yellow</option>
    <option value="red">Red</option>
    <option value="green">Green</option>
  </select>
</div>
like image 122
kravis Avatar answered Sep 16 '22 21:09

kravis