Positioning a menu list underneath a textbox with CSS -
i'm struggling css search box , list how want it. want list attached bottom of textbox , have no idea how that. here short of i've got far...
<style> ul.drop{display:inline-block;} ul.drop, ul.drop li { list-style: none; margin: 0; padding: 0; background: #ecf1f3; color: #28313f; } ul.drop li.hover, ul.drop li:hover { position: relative; z-index: 599; background: #1e7c9a;} </style> </head> <body> <label for="someinput">search ingredients</label> <input id="someinput"> <ul id="menu" class="drop" style="overflow:auto; max-height:200px;"> <a href="#"><li>ingredient1</li></a> <a href="#"><li>ingredient2</li></a> <a href="#"><li>ingredient3</li></a> <a href="#"><li>ingredient4</li></a> <a href="#"><li>ingredient5</li></a> </ul> <label for="qty"></label> <input type="text" size="5" name="qty" id="qty" /> g <button type="submit" name="add" id="add" value="add">add</button> </body>
the list showing right of box, directly underneath textbox. considering container div list, wasn't sure if necessary.
thanks help.
you have 2 options here both involve changing html following:
<div class="inputholder"> <label for="left someinput">search ingredients</label> <input id="someinput" /><br /> <ul id="menu" class="drop" style="overflow:auto; max-height:200px;"> <li><a href="#">ingredient1</a></li> <li><a href="#">ingredient2</a></li> <li><a href="#">ingredient3</a></li> <li><a href="#">ingredient4</a></li> <li><a href="#">ingredient5</a></li> </ul> </div> <div class="inputholder"> <label for="qty">g</label> <input type="text" size="5" name="qty" id="qty" /> <button type="submit" name="add" id="add" value="add">add</button> </div>
then if want have list appear above further content (ie content pushed down), need following styles:
.inputholder {float:left; margin-right:10px;} #menu {margin-left:7.5em}
if want list appear on top of (overlapping) further content, can use these styles:
.inputholder {float:left; margin-right:10px; position:relative;} #menu {position:absolute; left:7.5em; top:1.5em;}
Comments
Post a Comment