在html中居中显示按钮

在html中居中显示按钮,html,blogger,Html,Blogger,我正在尝试在我的博客帖子中放置一个按钮。我已经设计了这个按钮,但是我无法在页面上正确居中 我怎么把这个按钮居中 <html> <head> <style> .button { background-color: #4CAF50; border: none; color: white; padding: 15px 32px; text-align: cente

我正在尝试在我的博客帖子中放置一个按钮。我已经设计了这个按钮,但是我无法在页面上正确居中

我怎么把这个按钮居中

<html>
  <head>
    <style>
      .button {
        background-color: #4CAF50;
        border: none;
        color: white;
        padding: 15px 32px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        margin: 4px 2px;
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <h2>Buttons</h2>

     
    <a class="button" href="#">Link Button</a>
    <button class="button">Button</button>
  </body>
</html>


    

.按钮{
背景色:#4CAF50;
边界:无;
颜色:白色;
填充:15px 32px;
文本对齐:居中;
文字装饰:无;
显示:内联块;
字体大小:16px;
利润:4倍2倍;
光标:指针;
}
按钮
按钮

使用
边距:0自动

。按钮{
背景色:#4CAF50;
边界:无;
颜色:白色;
填充:15px 32px;
文本对齐:居中;
文字装饰:无;
显示:内联块;
字体大小:16px;
利润:4倍2倍;
光标:指针;
}
身体{
文本对齐:居中;
}
按钮

按钮
这是否回答了您的问题?将按钮包装在具有100%宽度和
文本对齐:居中的div元素中。