Using native drop-down lists (select) on the mobile side will have their own style, what do you want to do with a custom style?
The first step is to get rid of the default style:-webkit-appearance:none; These types of properties under input, such as type= "date", will remove the default style, but this time the border of the select setting, Styles, such as width or text centering, do not work. This is the time to simulate the Select box. The select tag is still used because select uses the default bullet box on the mobile side.
Final effect
The HTML structure is as follows:
1 <Divclass= "Select-area">2 <spanclass= "Select-value"></span>3 <Select>4 <option>Gansu</option>5 <option>Lanzhou</option>6 </Select>7 </Div>
Select-value is used to store the value of the dropdown box selected, hide Select, and then use JS to control the value of the drop-down box displayed.
the corresponding styles are as follows:
1 . Select-area{2 position:relative;3 Overflow:Hidden;4}5 . Select-area Select{6 position:Absolute;7 Left:0;8 Top:0;9 Opacity:0;Ten width:100%; One}
The next step is to use JS to control the display of the selected values:
1$ (". Select-area. Select-value"). each (function(){2 if( $( This). Next ("select"). Find ("option:selected"). Length! = 0 ){3$( This). Text ($ ( This). Next ("select"). Find ("option:selected")). text ());4 }5 });6$ (". Select-area select"). Change (function(){7 varValue = $ ( This). Find ("option:selected"). text ();8$( This). Parent (". Select-area"). Find (". Select-value")). Text (value);9});
The end result is the effect on the phone as shown.
Mobile-analog drop-down list