css - 以CSS菱形居中文本

标签 css

我对 CSS 非常陌生,正在尝试在我的 WordPress 主题上编辑 CSS。我正在尝试将每篇博客文章上的日期文本更改为居中的菱形。现在,我无法让菱形在柱子上居中。

请原谅极其凌乱的 CSS。我知道这很糟糕。

.post_detail post_date {
   width: 100%;
   float: left;
   margin-bottom: 20px;
   text-align: center;
}
.post_info_date {
  background: #fff;
  height: 60px;
  text-align: center;
  transform:rotate(45deg);
	width: 60px;
  position: inherited;
  bottom: 20%;
}
.post_info_date span {
  color: #333;
  display: table-cell;
  height: 60px;
  transform: rotate(-45deg);
  vertical-align: middle;
	width: 100%;
}

最佳答案

利用 line-height 属性。

CSS

.post_info_date span {
  color: #333;
  display: block;
  transform: rotate(-45deg);
  vertical-align: middle;
    width: 100%;
  line-height:60px;
}

相应的样式。

希望这有帮助..

关于css - 以CSS菱形居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45517598/

相关文章:

javascript - 从 .js 文件中提取动态菜单并在 html 中显示

javascript - jQuery Mobile - 在 changePage 上设置目标页面的滚动位置

css - 如何为 960 网格网页设计调整图像大小?

python - Flask 渲染以前版本的 CSS

javascript - 通过 Javascript、Html5 通过键盘在用户的杯子上写自定义文本

css - 无论内容如何,​​都将元素放在一行上

css - 如何隐藏边框下方的背景

jquery - 使用jquery时添加动画

javascript - 如何处理angularjs中的css和自定义指令

html - 排队脚本未显示在头部