html - 定位到超链接父级的中心

标签 html css

我有一个看起来像这样的超链接:

<a id="addNew" class="newEvent" href="/html/addNew.html">
    <label class="add">+</label>    
</a>

这些的 CSS:

.newEvent {
    position: fixed;
    bottom: 6vw;    
    right: 6vw;
    height: 10vw;
    width: 10vw;
    border-radius: 50%;
    border-color: transparent;
    background-color: #ce0808;
    box-shadow: 3px 3px 5px #888888;    
    align-content: center;
}

.add {
    font-size: 6vw;
    color: #ffffff;
    position: relative;
}

没有明显的原因,+ 符号向左对齐。 请注意,我尝试了那些 text-alignmargin: 0 auto 等我在网上找到的解决方案,但都没有用,我得到的最好的是水平居中,但是对齐到顶部。我需要帮助才能最终使 + 符号居中。

最佳答案

您省略了显示类型。我假设您想使用基于 align-items 的 flexbox?

.newEvent {
  position: fixed;
  bottom: 6vw;
  right: 6vw;
  height: 10vw;
  width: 10vw;
  border-radius: 50%;
  border-color: transparent;
  background-color: #ce0808;
  box-shadow: 3px 3px 5px #888888;
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
}

.add {
  font-size: 6vw;
  color: #ffffff;
  position: relative;
}
<a id="addNew" class="newEvent" href="/html/addNew.html">
  <label class="add">+</label>
</a>

关于html - 定位到超链接父级的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46528392/

相关文章:

html - onselect 事件不会在 div 上触发

html - 如何防止 WebView 缩小呈现的网页?

css - css 中的空声明导致 IE8 错误

html - 如何使用 CSS 制作 X 线性渐变效果?

python - 如何使用 BeautifulSoup 获取页面上特定文本后面的一些内容?

javascript - <br> ng-repeat angular-js中的标签

css - Bootstrap 响应式行,单元格高度相同

javascript - CSS 堆栈 Angular 重复水平而不是垂直

javascript - 西蒙游戏在第 2 级中执行 3 个序列

html - 悬停时 anchor 元素不会改变颜色