html - Align Text box in dropdown towards left css -
need display text box left side of track. should like.
.dropbtn { background-color: #4caf50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #94cb32; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); z-index: 10; } .dropdown-content { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover { background-color: #f1f1f1 } .dropdown:hover .dropdown-content { display: block; } .dropdown:hover .dropbtn { background-color: #3e8e41; }
<div class="dropdown"> <a href="#">track</a> <div class="dropdown-content"> <input type="text" placeholder="orderid" id="button1" text="track"> <input type="button" value="track" /> </div> </div>
add following .dropdown-content
:
top: 0; right: calc( 100% + 5px );
note when hover 1 element show have careful placement. if there gap between parent element , child element you'll no longer hovering parent element , child disappear. fix need both elements touch 1 another. can making sure touch (butted next each other or overlap on another), add padding (which might not ideal if using background color) or use pseudo element. did latter added selector:
.dropdown-content:before { content: ''; display: block; position: absolute; width: 5px; top: 0; right: -5px; bottom: 0; }
this solution have show in image i'm not sure how want (are going to) handle space left of .dropdown
. reduced width of body
can see fly out.
body { width: 40%; margin: 25px auto; } .dropbtn { background-color: #4caf50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; } .dropdown { position: relative; display: inline-block; } /* fills gap between track , flyout continue show when moving mouse. */ .dropdown-content:before { content: ''; display: block; position: absolute; width: 5px; top: 0; right: -5px; bottom: 0; } .dropdown-content { display: none; position: absolute; top: 0; right: calc( 100% + 5px ); background-color: #94cb32; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); z-index: 10; } .dropdown-content { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover { background-color: #f1f1f1 } .dropdown:hover .dropdown-content { display: block; } .dropdown:hover .dropbtn { background-color: #3e8e41; }
<div class="dropdown"> <a href="#">track</a> <div class="dropdown-content"> <input type="text" placeholder="orderid" id="button1" text="track"> <input type="button" value="track" /> </div> </div>
Comments
Post a Comment