html - 在类中居中边框

标签 html css

这可能是一个可笑的问题,但出于某种原因,我似乎无法将这些人对齐,使他们完全居中。出于某种原因,边界框似乎在左边,但不确定为什么。有人可以帮忙吗...

jsfiddle。 http://jsfiddle.net/greggy_coding/b3k9Lhfz/4/

html 和 css

<div class="container-bottom">
            <a href="http://www.google.com" target="_blank" class="linkbutton">LEARN MORE</a>
            <h4><span></span>Click to find out more </h4>
            </div>


body {
    background: #fff;
}

.container-bottom h4 {
  font-weight: 500;
  font-size : 16px ;
  text-align:center;
  color: #fff;
  margin-left : auto;
  margin-right : auto;
}

.linkbutton{
    border: 2px solid #fff;
    padding: 10px 50px; 
    width: 50px;
    border-radius: 30px;
    margin: auto;
    position: relative;
}
.container-bottom{
    background-color: #000;
    width: 300px;
    height:20%;
    padding: 25px;
    position: relative;
   margin-left: auto ;
  margin-right: auto ;
  margin-top:30px;

  }

最佳答案

该链接是内联的,因此 margin: auto; 将不起作用。

改为在父元素上使用 text-align: center;

.container-bottom {
    . . . 
    text-align: center;
}

关于html - 在类中居中边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30608982/

相关文章:

html - 具有 slideDown 和 slideUp 效果的 css 和 jquery 中的响应式菜单

javascript - 为什么超链接在 IE 11 中不起作用?

html - Django 和 HTML 数组

javascript - 像按钮动画这样的单个帖子有效,但多个帖子意味着第一个帖子按钮仅有效

css - 仅在 iPad 的 Web 应用程序中禁用按钮

html - 文本消失在容器后面

javascript - 添加和减去额外的类

jquery - 显示/隐藏 div jQuery

html - 图片上的文字顶部居中对齐

html - 更改分辨率时防止选择元素换行