Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a Down Arrow to Select Drop Down

Tags:

html

css

razor

Hello I'm creating an MVC Razor site and I currently have a styled drop down box, Here is the jsfiddle. I can't figure out how to add a down arrow. Any ideas? I've tried this but it didn't work for me. Here is my current code

HTML

<div class="dropdown">
    <select>
        <option>Option One </option>
        <option>Option Two </option>
        <option>Option Three </option>
    </select>
</div>

CSS

.dropdown select{
  background:transparent;
   width: 297px;
   padding: 2px;
   font-family:Arial, Helvetica, sans-serif;
   font-size:1.2em;
   font-weight:600;
   color:#fff;
   line-height: 1;
   border: 0;
   border-radius: 0;
   /*Hides the default arrows for Selects*/
  -webkit-appearance: none;
  -moz-appearance: none;
    text-indent: 0.01px;
    text-overflow: '';

  }


.dropdown{
    width: 297px;
    overflow: hidden;
    background: no-repeat right #363636;
    border-top:#575757 1px solid;
    -webkit-border-radius: 4px 4px 4px 4px;
     -moz-border-radius: 4px 4px 4px 4px;
          border-radius: 4px 4px 4px 4px;
    -webkit-box-shadow: inset 0 2px 4px rgba(107, 105, 105, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
     -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
          box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
          -moz-box-shadow:    0px 8px 3px -9px #000000;
          -webkit-box-shadow: 0px 8px 3px -9px #000000;
          box-shadow:         0px 8px 3px -9px #000000;  

}

select > option {
  background: #D3D3D3;
  color: black;
like image 841
joetinger Avatar asked Apr 10 '14 20:04

joetinger


People also ask

How do you customize a drop down list?

On the worksheet where you applied the drop-down list, select a cell that has the drop-down list. Go to Data > Data Validation. On the Settings tab, click in the Source box, and then change your list items as needed. Each item should be separated by a comma, with no spaces in between like this: Yes,No,Maybe.

How do I move a drop down arrow in Excel?

The simplest fix is once you select a value from the drop down, move the focus to the left or right to hide that drop down arrow.


1 Answers

You could create this triangle via css and pseudo elements

.dropdown {
    position: relative;
}

.dropdown:before {
    content: "";
    position: absolute;
    right: 10px;
    top: 8px;
    width: 0; 
    height: 0; 
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #f00;
}

.dropdown:after {
    content: "";
    position: absolute;
    right: 10px;
    top: 3px;
    width: 0; 
    height: 0; 
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #333;
}

Here is a demo : http://jsfiddle.net/S3h27/363/

like image 122
Vangel Tzo Avatar answered Oct 15 '22 13:10

Vangel Tzo