otuatail Posted July 11, 2015 Share Posted July 11, 2015 (edited) <div style="height:40px;width:300px;margin-top:15px;clear:both;border:solid;"> <input type="submit" value=" Update Teams "> </div> Hi I have tried margins and borders both top and bottom I just want the submit button vertically centred. This is part of another div hence the clear:both; TA Driving me mental... Edited July 11, 2015 by otuatail Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 11, 2015 Share Posted July 11, 2015 A margin on the input works fine: https://jsfiddle.net/hm7hwgun/ Quote Link to comment Share on other sites More sharing options...
maxxd Posted July 11, 2015 Share Posted July 11, 2015 Try this in your CSS: #my-button{ position: absolute; top: 50%; -ms-transform: translateY(-50%); -webkit-transform: translateY(-50%); transform: translateY(-50%); } Obviously change the #my-button identifier to whatever ID you're using for the button, and make sure the surrounding container has a position: value of either 'absolute' or 'relative'. Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 11, 2015 Share Posted July 11, 2015 I simply added the display and vertical-align attr to your code and tested fine in firefox. <div style="height:40px;width:300px;margin-top:15px;clear:both;border:solid;display: table-cell;vertical-align: middle"> <input type="button" value=" Update Teams " style=""> </div> Quote Link to comment Share on other sites More sharing options...
denno020 Posted July 13, 2015 Share Posted July 13, 2015 (edited) If you want to use flexbox: div { display: flex; align-items: center; } More info on flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ Edited July 13, 2015 by denno020 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.