]."/> ].">
Home > Article > Web Front-end > How to achieve centered display of buttons in css
Let’s take a look at the effect first:
(Recommended tutorial: CSS tutorial)
This can be achieved through simple CSS styles
<div style="margin:0 auto;width:200px;"> <input class="submit" id="btn" type="submit" value="注册" /> </div>
Use margin-left:auto;margin-right:auto; to center align your div.
.style{margin-left:auto;margin-right:auto;} The abbreviation is: .style{margin:0 auto;} The number 0 means that the top and bottom margins are 0. Can be set to different values as needed. The width after
is also a very important attribute, because the width of the button is very small, so you need to set a suitable width value to center your button.
The above is the detailed content of How to achieve centered display of buttons in css. For more information, please follow other related articles on the PHP Chinese website!