Get a Select elements Options to "right-width" and leave the width of the Select itself unchanged - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:id

Description

Get a Select elements Options to "right-width" and leave the width of the Select itself unchanged

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.select-wrapper {
   position:relative;
   width:201px;
   overflow:hidden;
   border:2px solid Chartreuse;
}

.select-wrapper::after {
   content:"\2194";
   position:absolute;
   right:6px;
   top:0;
}

.select-wrapper select {
   background:transparent;
   border:0;
   padding:4px;
}
</style> <!--from   ww w  .  ja v  a  2s  .co m-->
 </head> 
 <body> 
  <div class="select-wrapper"> 
   <select> <option value="" disabled selected>Lorem ipsum dolor </option> <option>Lorem ipsum </option> <option>Lorem ipsum dolor sit amet, consectetur</option> </select> 
  </div>  
 </body>
</html>

Related Tutorials