The code needed is very simple as shown by w3schools:
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_form_select&stacked=h
Just add a label and a class of "form-control"
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
But the result is inconsistent; some borders are black, and some are transparent. It looks weird to me. Is my sense of style just off?
Checking out bootstrap docs it looks like the correct way to do it. Is it supposed to look like that?
I tried for example to add a class and style it:
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control dropdown" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
CSS:
.dropdown {
border: transparent !important
}
No effect. What do you think?
Thanks in advance
You've hit a very interesting feature of the internet -- native form controls.
The border that you are encountering is the system styling of what appears to be internet explorer / edges rendering system. This can't necessarily be styled with CSS.
You could recreate the dropdown using CSS / JavaScript, but you would lose a lot of the functionality that inherently comes with that specific control.
For example, when you are on a mobile device the select / option control sometimes becomes a spin wheel / rolodex at the bottom of your view port. You also lose the keyboard / autocomplete functionality when users try to select an item via a keyboard ( I live in Minnesota, when presented with a state dropdown I type M -> selects Maine, I -> Selects (Mi)nnesota.
When developers rebuild this type of control with autocomplete functionality what tends to happen is I type M -> Maine, I -> Idaho.
Ultimately what you choose to do is up to you, but to eliminate some of the border weirdness could actually cause a user experience that is less robust than just letting it be.
As an aside most browsers implement select / option controls differently. See three different browsers below:
Related
I'm using Clarity and Bootstrap together in an Angular project, but styling conflicts seem to be popping up, as the styling is not working as intended.
I've tried changing the CSS around in Chrome devtools. I noticed that reboot.scss might be causing some of the problems, but I don't know what to do about that if it is.
Here's the component code.
<h3>New Post</h3>
<form #productEditorForm="ngForm" clrForm>
<clr-select-container>
<label>Location</label>
<select clrSelect name="Location" [(ngModel)]="LocationID">
<option *ngFor="let location of Locations" [value]="location.ID">{{ location.Name }}</option>
</select>
</clr-select-container>
<clr-input-container>
<label>Images</label>
<input clrInput #files type="file"/>
</clr-input-container>
<button class="btn btn-primary" type="submit">Post</button>
</form>
The expected appearance of the selectbox is like the examples found here. The expected appearance for the button is like the primary button found here; the font size of the buttons is supposed to be .5rem, but the actual size is 1. The intended default font is Metropolis, but the actual font is Segoe UI. The page isn't supposed to have flickering scrollbars and jittery contents, but the actual page does. Where do I go from here?
There are many Angular carousel implementations (this one is built upon Bootstrap but is able to be used in an isolated way https://ng-bootstrap.github.io/#/getting-started) and they would be able to provide the necessary functionality.
If you do load Bootstrap, you would want to load it before Clarity so Clarity has the final say on the styling.
I have a page that uses Bootstrap 4 with a single input control that was working okay. My problem is when I add help it adds it on the same line rather than the next line beneath the control as I would expect.
My suspicion is it that it is a problem with input-group/form-group. Im finding the generally very good Bootstrap documenentation very unclear on how these two things fit together since Im using inputgroups as the field label.
This is the html
<div class="input-group">
<div class="input-group-prepend">
<label for="undoLocation" id="undoLocationlabel" class="input-group-text">
Find songs
</label>
</div>
<select class="custom-select" name="undoLocation" id="undoLocation" aria-describedby="undoLocationHELP">
<option value="0">
that are currently in the selected locations
</option>
<option selected="selected" value="1">
that were originally in the selected locations
</option>
</select>
<small id="undoLocationHELP" class="form-text text-muted">
When files have been moved by SongKong you can use this option to find files currently in the selected all location or find files that were originally in the selected location
</small>
</div>
and I have created a jsfiddle.
https://jsfiddle.net/paultaylor/g64v96fy/1/
According to Bootstrap discussion:
Block help text—for below inputs or for longer lines of help text—can be easily achieved with .form-text. This class includes display: block and adds some top margin for easy spacing from the inputs above.
However, you added it to a parent element with a input-group class, by nature will display with the group, inline. Additionally, you used an HTML default inline tag <small> which also displays, by nature, inline.
Per specs:
The small element should not be used for extended spans of text, such as multiple paragraphs, lists, or sections of text. It is only intended for short runs of text...
Even if you do what's recommended and wrap it in a <p> tag, the parent still defines the style, and input-groups by nature are inline.
So, it's recommended to move it outside of the div.
<div class="input-group">
<div class="input-group-prepend">
<label for="undoLocation" id="undoLocationlabel" class="input-group-text">
Find songs
</label>
</div>
<select class="custom-select" name="undoLocation" id="undoLocation" aria-describedby="undoLocationHELP">
<option value="0">that are currently in the selected locations</option>
<option selected="selected" value="1">that were originally in the selected locations</option>
</select>
</div>
<p id="undoLocationHELP" class="form-text text-muted">
When files have been moved by SongKong you can use this option to find files currently in the selected all location or find files that were originally in the selected location
</p>
I have this dropdown list but problem is when i run it in IE it goes up and down if i select something from bottom or middle.How can fix so that it expand it always bellow:
https://jsfiddle.net/tq1bhfno/ (you need to run it in IE)
<div class="col-lg-2 col-md-2">
<div class="select-wrapper">
<select name="gametype" id="gametype" ng-model="selectGameType">
<option>TEST1</option>
<option>TEST2</option>
<option>TEST3</option>
<option>TEST4</option>
<option>TEST5</option>
<option>TEST6</option>
<option>TEST7</option>
</select>
</div>
</div>
Drop-downs are rendered by the Browser/OS. You cannot control this type of behaviour using CSS or JavaScript.
What about the dropdown itself?
As in, the thing that shows the choices when activated. As far as I know, there is no way to style these in any browser. Not even bold or italic. The closest thing to style you can get is grouping them by using . This is probably mostly a UI thing, but it might be a security thing too. You wouldn't want people doing tricky things with fonts that make it unclear what option is selected.
Read More About Dropdown Default Styling
See the behavior without any CSS:
https://jsfiddle.net/tq1bhfno/2/
Only the HTML:
<div class="col-lg-2 col-md-2">
<div class="select-wrapper">
<select name="gametype" id="gametype" ng-model="selectGameType">
<option>TEST1</option>
<option>TEST2</option>
<option>TEST3</option>
<option>TEST4</option>
<option>TEST5</option>
<option>TEST6</option>
<option>TEST7</option>
</select>
</div>
It is the same.
bottom: 100%;
add this attribute to your css for dropdown. This forces to show everything below.
Attached you can see a picture, which is a form that clients should use to contact me. As you can see, the select form is not in the same layout than the others. I want to add an icon as well, but it looks stupid because it is a rect closed to round corners. I have found many ways to change that, but with huge libraries, which I don't need (e.g. http://ivaynberg.github.io/select2/ or http://silviomoreto.github.io/bootstrap-select/)
https://dl.dropboxusercontent.com/u/20731482/contact.png
How can I change the layout and include the icon on the left side easily?
Why don't you use a regular select ?
<div class="input-prepend">
<span class="add-on">#</span>
<select id="inputSelection">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
You can see how it works.
I'm using jquery mobile for my project. It automatically converts all radio buttons in its inputs with its styles. The major problem is that in different situations i have different number of buttons (it depends on user) with its different width and i need it every time center.
<div data-role="fieldcontain" id="inline" >
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">
{section name=i loop=$data['input'] start=0}
<input name="position" id="radio{$smarty.section.i.index}" value="{$data['input'][i]}" type="radio" />
<label for="radio{$smarty.section.i.index}">
{$data['input'][i]}
</label>
{/section}
</fieldset>
</div>
As you see each button has his size (for example Up and Zoom In are different). As i said before - i don't know what buttons will be for each users - it depends on their own settings, so i need somehow automatize process of centering it - is some ideas?
You could try it with <a> instead of <input> as done in the documentation, if at all possible in your situation.