solution for ui component that combine text input and dropdown - semantic-ui

Is there a semantic-ui ready-to-use solution for ui component that combine text input and dropdown of predefined values. The sample is "A dropdown menu can appear to be floating below an element" (http://semantic-ui.com/modules/dropdown.html), but it would be text input instead of button.

ContentEditable Solution:
Try using the new html5 element, "contenteditable".
e.g.
Original standard Semantic UI code:
<div class="ui selection dropdown">
<input type="hidden" name="gender">
<div class="default text">gender</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="Male">Male</div>
<div class="item" data-value="Female">Female</div>
</div>
</div>
New Modified Code with contenteditable:
<div class="ui selection dropdown">
<input type="hidden" name="gender">
<div class="text" contenteditable="true"></div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="Male">Male</div>
<div class="item" data-value="Female">Female</div>
</div>
</div>
Notice 3rd line is modified in several ways.
I removed the "default" class since I don't want the grey placeholder effect.
I added contenteditable attribute.
And I also removed the placeholder text.
Now you need a JQuery event handler that handles that div's onChange event, or the form's submit's button click event so that you can copy the div's value to the hidden text input.
Datalist HTML5 Solution:
If you strictly don't need the dropdown styling semantic UI provides, such as option dividers, then you can use:
<div class="ui input">
<input list="browsers" type="text">
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</div>

Related

Button position middle row on form-inline Bootstrap 4

I'm making a form-inline using Bootstrap 4, but when I use a button, the position of the button is always at the top of the row, I want the button's position to be the same as the input field's position, which is in the middle of the row.
<form role="form" id="form_tambah_kriteria" class="margin-bottom-0">
<div class="form-row">
<div class="form-group col-md-4">
<label>Tipe Decision Maker</label>
<div class="input-group">
<div class="input-group-append"><span class="input-group-text"><i class="ion-ios-contacts"></i></span></div>
<input type="text" name="tipe_dm[]" class="form-control" placeholder="Tipe Decision Maker">
</div>
</div>
<div class="form-group col-md-4">
<label>Owned by:</label>
<div class="input-group">
<select class="form-control" name="owner_dm">
<option value="">0</option>
<option value="1">1</option>
</select>
</div>
</div>
<button class="btn btn-danger">Delete</button>
</div>
</form>
The following is Codepen
The simple fix is to wrap the button in a form-group and prefix it with some invisible text ( or <br />). But it would be dead wrong, just a handy hack, because it would simply hide the underlying problem with your codepen.
The proper fix would be to:
use latest stable version of Bootstrap - your pen currently uses v4.0.0-alpha5 which doesn't contain a lot of bugfixes and, among others, does not contain Bootstrap's flexbox classes)
wrap the button in a .form-group.col-md-4
use d-flex align-items-end classes on the .form-row
Working example: https://codepen.io/andrei-gheorghiu/pen/KKKNxZg
Note: until you start using the latest stable version of Bootstrap's CSS, you'll keep running into problems which seemingly don't make any sense, because the version you're using is a pre-release which does not include a lot of what most Bootstrap 4 examples take for granted.
the solution is easy just add <br> before the button Delete for new line...like this:
<br> <button class="btn btn-danger">Delete</button>
You should put the button in the third column grid and use the <br /> .
you should do it as below:
<div class="form-group col-md-4">
<br />
<button class="btn btn-danger">Delete</button>
</div>

Bootstrap tooltips moves up has-feedback icon

When using the has-feedback class to add an icon on a form field and using the bootstrap tooltip, the icon moves up. I get the same behavior with chrome, firefox and ie.
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="form-group form-group-lg has-feedback">
<input class="form-control" name="foo" placeholder="foo" data-toggle="tooltip" title="Hooray!" type="text">
<span class="glyphicon glyphicon-euro form-control-feedback"></span>
</div>
</div>
</div>
JS File
$('[data-toggle="tooltip"]').tooltip();
Here the example
Bootply
Does anyone know how to solve this problem? Thank you
The reason for it failing is this Bootstrap selector:
.form-group-lg .form-control+.form-control-feedback {...}
When you hover the field, the tooltip's <div> is inserted immediately after the input, thus breaking the + condition since the icon is no longer immediately following the input. A solution is to move the tooltip on the parent element, so that it doesn't interfere with children styling:
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="form-group form-group-lg has-feedback" data-toggle="tooltip" title="Hooray!">
<input class="form-control" name="foo" placeholder="foo" type="text">
<span class="glyphicon glyphicon-euro form-control-feedback"></span>
</div>
</div>
</div>
Demo: http://www.bootply.com/tohoEsh0cX

Is it possible to dynamically change the font on radio buttons with CSS?

I was trying to do this with jquery (How do I get javascript to run more than once?) but some people said it can be done easier with CSS. Right now I have JS that dynamically adds and removes the ez-selected class as seen below whenever a radio button is selected. This is used to replace the buttons with images.
Is there any way to use CSS so that when the ez-selected class is added, it turns the text in the span tag to bold and then removes the bold when the ez-selected class is removed? I cannot change the HTML structure as it's coded in my shopping cart software. Thanks!
EDIT: Is there any kind of CSS selector that can style the span closest to the input checked? I know with + it can select an element right after another element, but is there a way to just select the next span element after a checked radio button even if that span is in another div?
<div class="row">
<input name="TXT870" type="hidden" value="Option 1">
<div class="col-xs-2">
<div class="ez-radio (ez-selected)">
<input class="clearBorder ez-hide" name="CAG3" onclick=
"javascript:document.additem.CAG3QF1.value='1'; CheckPreValue(this, 2, 0);"
type="radio" value="870_625_0_625">
</div><input name="CAG3QF1" type="hidden" value="0">
</div>
<div class="col-xs-7">
<span>Option 1</span> <input class="transparentField" name=
"CAG3TX1" readonly size="14" type="text" value=" - Add $5.00">
</div>
</div>
The .ez-selected div is not a previous sibling or parent of the span...so NO...you can't.
Not with this structure
<div class="row">
<input name="TXT870" type="hidden" value="Option 1">
<div class="col-xs-2">
<div class="ez-radio ez-selected">
<input class="clearBorder ez-hide" name="CAG3" onclick=
"javascript:document.additem.CAG3QF1.value='1'; CheckPreValue(this, 2, 0);"
type="radio" value="870_625_0_625">
</div><input name="CAG3QF1" type="hidden" value="0">
</div>
<div class="col-xs-7">
<span>Option 1</span> <input class="transparentField" name=
"CAG3TX1" readonly size="14" type="text" value=" - Add $5.00">
</div>
</div>
You would have to travel up the DOM first and you can't do that with CSS because there is no parent selector

Inline Block input in a form with Bootstrap

I have a form with some inputs and I can't figure out how to put these inputs inline with Twitter Bootstrap. I am new to Twitter Bootstrap.
Here is my code:
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on"> <i class="icon-lock"></i>
</span>
<input path="q1" class='input-xlarge' type='text' value='Name of my father'readonly="yes"/>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on"> <i class="icon-lock"></i>
</span>
<input path="r1" class='input-xlarge' type='text' value='' autofocus="autofocus" />
</div>
</div>
</div>
Here is a jsFiddle with my code to well understand my problem: http://jsfiddle.net/XHPMH/1/
Using inline-style attribute I have the result I'm expecting, but I would like to use as many as possible Twitter Bootstrap : http://jsfiddle.net/5Z3rP/
Edit: I'm performing client side validation with jQuery-validation, so I think I have to keep control-group css class
Look at the "Inline Form" section here: http://getbootstrap.com/2.3.2/base-css.html#forms
<form:form class="form-horizontal form-validate form-inline" method="POST" acceptCharset="UTF-8">
http://jsfiddle.net/5Z3rP/1/
I also removed the ".controls" div, which was unnecessary and preventing the inline style.

Bootstrap: Mixing buttons and input boxes

Please see this fiddle, where I have a button and three input boxes and I'm using Bootstrap.
<div class='container'>
<div class='row'>
<form class='span10'>
<input type='text' placeholder='Label' id='new-row-label' class='span3'>
<input type='text' placeholder='Orders' id='new-row-orders' class='span2'>
<input type='text' placeholder='Items' id='new-row-items' class='span2'>
<div class='btn span2' id='add-row'>Add new item</div>
</form>
</div>
</div>​
Two things are wrong here:
The button is slightly lower than the input box.
The button is on the left hand side, when in my code it appears after the input boxes.
How can I have three input boxes and a button, all aligned at the same height, with the button on the right?
If you add pull-right class with btn like this
<div class='btn pull-right span2' id='add-row'>Add new item</div>
it'll float the button at the right side like this example but it doesn't seems lower to me.
Use the form classes to make an inline form:
<form class="form-inline">
<div class="row">
<input type='text' placeholder='Label' id='new-row-label' class='span3'>
<input type='text' placeholder='Orders' id='new-row-orders' class='span2'>
<input type='text' placeholder='Items' id='new-row-items' class='span3'>
<button type="button" class="btn" id='add-row'>Add new item</button>
</div>
</form>
The class="span10" on the FORM tag was also throwing off the layout.
http://twitter.github.com/bootstrap/base-css.html#forms

Resources