Home > Web Front-end > CSS Tutorial > How to achieve centered display of buttons in css

How to achieve centered display of buttons in css

王林
Release: 2020-08-20 16:55:33
forward
6033 people have browsed it

How to achieve centered display of buttons in css

Let’s take a look at the effect first:

(Recommended tutorial: CSS tutorial)

How to achieve centered display of buttons in css

This can be achieved through simple CSS styles

<div style="margin:0 auto;width:200px;">
<input class="submit" id="btn" type="submit" value="注册" />
</div>
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template