Got a nice menu with rounded buttons, and I want to style the dropdown list the same way. Tried a lot of different things but there is two things I need some help with:
1. rounded corners like the rest of the buttons.
2. get a solid color, and not that animated look.
Here is a picture showing the buttons and the dropdown:
Here is the styling on the list:
#topNav .right #categoryButton {
margin-top:5px;
border:3px solid #fff;
background-color:#303030 ;
text-transform:uppercase;
color: #fff;
height:50px;
width:220px;
outline: none;
}
Check out this great article about styling a select dropdown. There are limitations however and some older browsers will render the select box its own way.
It basically involves wrapping the select in a div and styling the div:
.styled-select select {
background: transparent;
width: 268px;
padding: 5px;
font-size: 16px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;
}
.styled-select {
width: 240px;
height: 34px;
overflow: hidden;
background: url(new_arrow.png) no-repeat right #ddd;
border: 1px solid #ccc;
}
<div class="styled-select">
<select>
<option>Here is the first option</option>
<option>The second option</option>
</select>
</div>
You can't do that. You have to build your own select element.
From this article discussing "What if you want complete design control?"
First, try everything you
can to make that not necessary. Default form elements are familiar and
work well. Making a dropdown menu match the font and colors of your
brand isn't usually necessary and is more likely obnoxious at best and
bad UX at worst.
If you decide that it's absolutely a good idea to customize a
dropdown, then you should use JavaScript to:
Accessibly hide the original select.
Rebuild the select with custom
markup (probably a definition list), that you style how you want.
Replicate all the functionality that default selects have, which
include: keyboard events like up and down arrow keys and return to
select, scrolling of long lists, opening the menu upwards when select
is against bottom of screen, to name a few.
There's a few more steps to accommodate different client setups and a tutorial linked for more information.
Related
I have a login page with two fields:
<select id="operatore" name="operator">
<option disabled selected>Operator</option>
<option>John</option>
<option>Jennifer</option>
<option>Carl</option>
</select>
<input type="password" placeholder="Password" id="search_field" readonly>
I want that all the text appears centred. In Firefox all works fine. But in Chrome the written "Operator" appears on the left, even if the style inspector doesn't cancel the style, as you can see from the image:
In the native app for surf the net in Samsung Tablet, the written "Operator" appears centered, but the placeholder "password" appears on the left. Why? How can I fix all these problems?
HERE is the full CODE.
you can give it a text indent like text-indent: 40px;this won't make it aligned center but it will move it to the middle
and by the way there is a better way of making a placeholder for the select
<option style="display: none;" value="">Operator</option>
this way it won't show up in the drop-down
Taken from: Is it possible to center text in select box?
I'm afraid this isn't possible with plain CSS, and won't be possible to make completely cross-browser compatible.
However, using a jQuery plugin, you could style the dropdown:
http://filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/
This plugin hides the select element, and creates span elements etc on the fly to display a custom drop down list style. I'm quite confident you'd be able to change the styles on the spans etc to center align the items.
Ok, I believe I have fixed your Operator problem.
Here is the slightly changed code.
form input {/*ADDED*/
width: 250px;
}
form input, #operatore {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
border-radius: 3px;
padding: 10px 15px;
margin: 0 auto 10px auto;
padding-left: 90px;/*ADDED*/
padding-right: 80px;/*ADDED*/
/*TOOK AWAY width: 250px; PROPERTY*/
display: block;
text-align: center;
font-size: 18px;
color: white;
-webkit-transition-duration: 0.25s;
transition-duration: 0.25s;
font-weight: 300;
}
For some odd reason in Chrome the selector form input, #operatore is disabling any other changes made to (form) selector, option. Moreover if I were to add an extra selector, for example: #operatore {someCSS}, the (selector) form input, #operatore would STILL take precedence over that selector and I also used !important. Anyway you will have to align the text manually using padding-left and padding-right.
You can't really customise <select> or <option> much. The only way (cross-browser) would be to manually create a drop down with divs and css/js to create something similar.
Hi, I have a ASP dropdown control I need to add the CSS for it, I added this class:
select {
padding: 1px;
margin: 0;
background: #f8f8f8;
color: #888;
border-style: ridge;
outline: none;
display: inline-block;
background-image: url("Images/downarrow.png");
appearance: none;
cursor: pointer;
}
but the problem is in IE 8+ the dropdown image is not changing at all, does anyone have a solution?
You can't change the drop down arrow, this is native to each browser.
Theres ways of hacking this for particular browsers, but you'll never get this consistent across all.
The best option would be to use a dropdown plugin, which hides the drop down element, and renders a custom drop down in its place.
For example, you could use something like ddSlick, then customise this to meet your requirements.
How do I cleanly style a HTML + CSS horizontal tab bar so that the tab bar has a line across the bottom that's hidden or suppressed for the active tab?
In other words, I'm trying to do the same thing that StackOverflow does for its tags:
My tab bar is set up as an ordered list with
ul
{
list-style: none;
}
li
{
float: left;
}
Update: I've already poked around sites with Firebug to see how they do it, but I feel like I quickly get bogged down in details. For example, StackOverflow's version has a border for the bottom of the whole div (which makes sense), and a white border for the bottom of the active tab (which makes sense), but then it makes the active tab's border overlap the div's border (and I'm not very clear on how it does that). It looks like Twitter Bootstrap does something similar. I'm trying to understand the general concept of how overlapping part of a container's border with the content's border works instead of copying and tinkering with CSS until I get something that appears to work.
All you need to do is put a bottom border on the <ul> (so that it stretches across) and then give the <li>'s a selected class, and make that one have a 1-pixel higher height.
Here is a very simple example: http://jsfiddle.net/V6gzS/
ok to point you in the right direction use firebug or chromes element inspector and just pick out the bits you need, so on this site for example what you are looking for are called tabs and they are styled like so
#tabs a.youarehere {
background: #fff;
border: 1px solid #ccc;
border-bottom-color: #ffffff;
color: black;
font-size: 120%;
height: 30px;
line-height: 28px;
margin-top: 3px;
padding: 0px 11px 0px 11px;
}
this is just a part of it but you can learn a lot by looking at some code
As I understand it you are capable of making the buttons by yourself, with the horizontal bottom line.
If that is the case, then make sure that this horizontal line is made as a border-bottom: solid 1px #CCC property on each button (the color might be different). At each page you then add the id id="current" to that one button that is the active page. In CSS you write:
#current {
border: solid 1px #CCC;
border-bottom: 1px solid white;
}
If you have any problems it might be solved by adding !important like this:
border-bottom: 1px solid white !important;
Therefore, this is just four extra lines of code in CSS and one extra HTML attribute in each of the files.
If dynamic menu
If you have a menu that is not static on every page, but maybe dynamically generated or placed in an included file, then the above will not be possible. Because then you can't easily add the new id on each seperate page.
In that case you might do some dynamic adding of the attribute. If a server side language is used, e.g. PHP, then you might be able to easily set up an if{...} command that checks the URL or a GET request or alike. Else you might use some javascript to check each button and add the attribute id if the button text equals some header on the page.
I hope you understand. Good luck.
I did it like this:
ul {
list-style-type:none;
}
li{
float: left;
border-bottom: 1px solid #CCC;
}
li:hover{
float: left;
border: solid 1px #CCC;
border-bottom:none;
}
I read once how to create cross-browser rounded buttons with shadow using images, I lost my bookmarks unfortunately that's why I ask does anybody remember the technique.
There is left side picture i.e
And then very wide body image which ends up with right curved border/shadow like this :
So at the end you end up with one button which can be used with multiple sizes? I was googling this, but it seems noways everyone use css without images.
Does anybody knows how this technique is called or can refer me to the link? or give me code example, I'd appreciate any of those
When using an image for the start and one for end of the button, these technique is called "sliding doors" and there are myriads of search results with any search engine…
For an introduction read the A List Apart article: http://www.alistapart.com/articles/slidingdoors
But as Neurofluxation asked you in the comment above: Why the hell would you do that years after we have multiple other methods of styling a button in CSS? The A List Apart article for example is from 2003 - which is an age in Internet terms.
This technique is a variation of the "Sliding Doors" technique:
http://www.alistapart.com/articles/slidingdoors/
http://css-tricks.com/snippets/css/perfect-css-sprite-sliding-doors-button/
http://azadcreative.com/2009/03/bulletproof-css-sliding-doors/
Basically you use markup like this:
<button><span>Text</span></button>
Then style the span with the edge image to the side, overlapping the main background image of the parent element. Something like this:
button {
background:url(main-image.png) top right no-repeat;
border:0;
padding:0;
width:80px; /* with only 1 "door", you might need to set a width */
/* other resets may be necessary */
}
span {
background:url(left-door.png) left top no-repeat;
}
button, span {
height:37px; /* height of your sprite */
display:block;
}
Demo: http://jsfiddle.net/Kqs3m/
Your results may vary depending on your sprites and the natural width of the content.
Here's the technique which I think you are looking for (using the same images you attached):
HTML:
<a href="#" class="button">
<span>Small</span>
</a>
<a href="#" class="button">
<span>Large button</span>
</a>
CSS:
.button {
background: url('http://i.stack.imgur.com/htUHL.png') no-repeat left top;
padding-left: 9px;
height: 37px;
display: inline-block;
text-decoration: none;
color: #555;
text-shadow: 0 1px 1px #FFF;
font-family: sans-serif;
font-size: 0.8em;
}
.button span {
background: url('http://i.stack.imgur.com/ID6nO.png') no-repeat right top;
display: inline-block;
height: 37px;
padding: 5px 12px 5px 3px;
}
.button:hover span {
color: #333;
}
Link to the demo: http://jsfiddle.net/v284q/
Using CSS properties instead of images can make your applications faster.
In this case you could just use: Border-Radius, Box-Shadow combined with a gradient background.
Here you can find a good Gradient Editor:
http://www.colorzilla.com/gradient-editor/
How to use Border-radius and Box-shadow:
http://www.css3.info/preview/rounded-border/
http://www.css3.info/preview/box-shadow/
Good Morning,
I'm trying to use the Bootstrap Button Group to group a family of related elements together. These elements are only "effective" for a given calendar year so I'm trying to group the "past elements" together in an easy to display fashion. So far I really like using the bootstrap button group to do this as outlined here.
However, I am displaying multiple of these on a "list-like" view and all of these buttons really aren't easy on the eyes. What I'd like to do is instead of a button for the very first element, make it a link and just have the small caret button to the right side of that link if my uses wish to look at the past elements.
Does anyone know of an easy way to style this? To reword - I want the very top element to only be an (or something similar) and only have a button containing the caret symbol off to the side of it.
Thanks in advance!
If you look at bootstrap 2.1, which is a work in progress at this time, they introduce a new button stlye class .btn-link that would probably work for this
.btn-link {
color: #08C;
cursor: pointer;
background-color: transparent;
background-image: none;
border-color: transparent;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.btn-link:hover {
color: #005580;
text-decoration: underline;
background-color: transparent;
}
They don't seem to have included it in the button group documentation, so it may look a little funny.
http://jsfiddle.net/qtK95/4/