html - 更改自定义按钮的宽度

标签 html css

我想将自定义 button 居中,但似乎找不到解决方案。

我可以对齐它,但我不知道如何使 border 变小并且不占用 h1 的整个 width文本

HTML:

#button {
  color: #6E4E34;
  font-size: 30px;
  text-decoration: none;
  border: solid 2px #6E4E34;
  border-radius: 5px;
  padding: 10px;
  font-family: "PT Sans", sans-serif;
  display: flex;
  justify-content: center;
}
<div id="ImageMain">
  <div id="TextMain">
    <h1>Shop our Whole Selection</h1>
    <a href="#" id="button">Browse</a>
  </div>
</div>

最佳答案

你的意思是这样的?

设置#textMain

align-items: center;
display: flex;
flex-direction: column;
justify-content: center;

片段

#TextMain {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#button {
  color: #6E4E34;
  font-size: 30px;
  text-decoration: none;
  border: solid 2px #6E4E34;
  border-radius: 5px;
  padding: 10px;
  font-family: "PT Sans", sans-serif;
}
<div id="ImageMain">
  <div id="TextMain">

    <h1>Shop our Whole Selection</h1>
    <a href="#" id="button">Browse</a>

  </div>
</div>

关于html - 更改自定义按钮的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42753197/

相关文章:

html - 如何将 Bootstrap 按钮放在我想要的位置?

html - Opera 在选择元素上设置背景颜色时隐藏下拉列表中的文本

javascript - Jquery - 将下一个按钮添加到选项卡

css - 字体系列 : inherit; specific to mozilla firefox

html - 将样式作为显示 block 后不起作用

css - joomla 页面上的非移动 div/导航

php - 这是一种有效的更新方法吗

html - 如何在更大的缩放级别显示图像后的产品信息

javascript - 如何使容器 div 仅水平溢出而不对其内部 div 使用 "display:inline-block"?

javascript - 第一次单击 ATOM HTML 预览后下拉菜单自动关闭(不是浏览器)