html dropdownlist with custom style - html

How can I completely change the design of a element? i am trying to make drop down like following image, what i wrote is
<select>
<option value="0">Title</option>
<option value="1">Mrs</option>
<option value="2">Mr</option>
</select>
i am stuck at put custom image to open drop down list for dropdown and also how to style select element

Some form elements are notoriously hard to style with CSS alone and still appear visually the same across all browsers.
The recommended practice for styling SELECT elemets is generally to use a javascript solution as this will work cross-browser.
Have a look at Chris Coyle's article on this:
http://css-tricks.com/dropdown-default-styling/

You can't style elements such as select in such a way you described it. Things like background-color or border are possible.
Styling with CSS only could go as far like this:
select {
border-radius: 5px;
color: lightgrey;
font-weight: bold;
}
With this CSS you will have the round corners and the font changed.
What's not possible:
Change the icon
Change the background or font of the dropped down box
Try fiddling with javascript, nested divs and a hidden input field. Also a glance at http://jqueryui.com could help you quite much.

Related

Can't identify CSS or element controlling background color

I'm having trouble changing the background color of a certain button on a WordPress plugin.
The button and text are set to white and I'm trying to identify the CSS file that controls it, unfortunately I've had no luck within the inspect element of my browser.
It is incorporated in a popup form - so multiple other files come into play.
I changed the color within the browser during inspect but need a fix.
You can overwrite CSS attributes by setting !important after your definition or by defining the scope better (e.g. by writing body or html before the class selector).
make sure your css file is able to "access" the dom element – if the element is in an iframe the css wont work.
body .wpforms-page-button {
background-color: green !important;
}
Using !important is generally considered hacky. Both rules in your screenshot have the same CSS specificity in that they are both firing on input[type="submit"] and .button.
Without seeing the corresponding HTML I can't give you the exact syntax, but something like
.parentclassname input[type='submit'] and or .parentclassname .button should make your style more specific than the original rule and therefore give it precedence.
Did you try to set !important after the #fff; ?
like this:
input[type=submit] {
background-color: #fff!important;
}
the best way is to define the button in a class, so you can change only the color for this specific button. Otherwise it will changes all the buttons to color #fff if you put the css in a general style.

change the height of "option" only with css

For example,in the code,"option"is too low,I want to make it higher only with css(no javascript).
<select>
<option>Beijing</option>
<option>ShangHai</option>
<option>WuHan</option>
</select>
Since that <option> (and <select>) elements are rendered by the browser as a dropdown list, unfortunately you cannot style them, because their style is only controlled by the browser itself.
Change select > option to ul > li list and you can style as you want it yourself with Cross browser compatibility
You can use ul as alternative to style as you want, check this answer.
You can only make options bold or change the font-size, but it's not possible to change the space of the option.
option{font-size:20px;font-weight:bold;}
<select>
<option>Beijing</option>
<option>ShangHai</option>
<option>WuHan</option>
</select>
Options are rendered by the OS, not HTML, so the styling is limited.
line-height can be useful
-webkit-appearance: menulist-button this one can be used both will work
Try this:
option{
padding:10px 0;
}
JSFIDDLE DEMO
Also you can use the <optgroup> element to make it run in Chrome.
EDIT:-
Just saw that it is not reliable and cant be addressed perfectly for cross browser solutions.
MDN says:
Some elements simply can't be styled using CSS. These include all
advanced user interface widgets such as range, color, or date controls
as well as all the dropdown widgets, including , , and elements. The
file picker widget is also known not to be stylable at all. The new
and elements also fall in this category.
Alternative other than Javascript:
If possible then use Bootstrap's Dropdown.
If you're concerning about the mobile friendliness or the Google's mobile first SEO guidelines where the tappable items must not close to each other, then don't worry, modern mobile web browser will auto-adjust the item height for you.
Try This: change the height px to what you wish.
.a option { height: 50px; }

Bootstrap design idea

I would like to get an idea from you guys. I have 3 checkboxes that I would like to display one in each line inside a box, kind of like a text area. What Bootstrap tool would allow me to accomplish that?
I tried to create a text area and out my checkboxes in them, but the code is translated as text in the text area. So I could not do that. What's the way of doing it?
You shouldn't restrict yourself to using only Bootstrap elements when making your site. Bootstrap is just a collection of nifty elements; it's fine (and probably necessary) to make your own, too.
If you just want your checkboxes to be in a box with an outline, well, that's a bit too simple for there to be a corresponding Bootstrap element.
In the simplest form, the HTML and CSS for this would look like this JSFiddle.
Html
<div class='checkbox-container'>
<input type='checkbox' id='one'>
<label for='one'>Hello</label>
</div>
Css
.checkbox-container {
margin: 10px 0;
padding: 10px 0;
border: 1px solid #aaa;
}
If you want all of the checkboxes in a single box, then you can do that with just a bit more code. View on JSFiddle.
If for some strange reason you must only use use Bootstrap elements, ananda's answer is pretty good. Using the well element gives you a border, but also an inner shadow and a background color. View the well on JSFiddle
try putting them inside the 'well' element

CSS styles for select element are not applied in IE 7

CSS border and background color styles are not applied to the select element in IE7.
HTML Code:
<select class="select_box">
<option>xxx</option>
</select>
CSS code:
.select_box
{
border:1px solid #ddd;
background-color:#000;
}
Beyond the background-color sort of being applied (I changed your colours to red)..
There's nothing you can do, and no easy workaround.
If you really want to do this in IE7, you'll have to use JavaScript to swap the selects out; you can theme those however you like and it will work in all browsers (unless JavaScript is disabled, in which case you'd be left with what you had in the first place: a native select element).
Also relevant:
http://www.456bereastreet.com/archive/200701/styling_form_controls_with_css_revisited/
http://www.456bereastreet.com/lab/styling-form-controls-revisited/select-single/

Change border color on <select> HTML form

Is it possible to change the border color on a <select/> element in an HTML form?
The border-color style works in Firefox but not IE.
I could find no real answers on Google.
I would consinder enclosing that select block within a div block and setting the border property like this:
<div style="border: 2px solid blue;">
<select style="width: 100%;">
<option value="Sal">Sal</option>
<option value="Awesome">Awesome!</option>
</select>
</div>
You should be able to play with that to accomplish what you need.
As Diodeus stated, IE doesn't allow anything but the default border for <select> elements. However, I know of two hacks to achieve a similar effect :
Use a DIV that is placed absolutely at the same position as the dropdown and set it's borders. It will appear that the dropdown has a border.
Use a Javascript solution, for instance, the one provided here.
It may however prove to be too much effort, so you should evaluate if you really require the border.
No, the <select> control is a system-level control, not a client-level control in IE. A few versions back it didn't even play nicely-with z-index, putting itself on top of virtually everything.
To do anything fancy you'll have to emulate the functionality using CSS and your own elements.
select{
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=-1, OffY=-1,color=#FF0000) progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1,color=#FF0000);
}
Works for me.
You can set the border color in IE however there are some issues.
Argh... I could have sworn you could do this... just tested and realized I wasn't correct. The notes below still apply though.
in IE8 (Beta1 -> RC1) changing the border color or the background color/image causes a de-theming of the control in WindowsXP (the drop arrow and box look like Windows 95)
you still can't style the options within the select control very well because IE doesn't support it. (see bug #291)
Replacing the border-color with outline-color should work.
<style>
.form-error {
border: 2px solid #e74c3c;
}
</style>
<div class="form-error">
{!! Form::select('color', $colors->prepend('Please Select Color', ''), ,['class' => 'form-control dropselect form-error'
,'tabindex' => $count++, 'id' => 'color']) !!}
</div>