javascript - 如何旋转以中心为中心的文本旋转到数字

标签 javascript jquery css html

我的文本是九月,应该按我的意愿旋转,

现在我的问题是文本应该根据数字居中

如果我将文本更改为 ma​​y也应该以该数字为中心

我有一个屏幕,我想要如何输出

EXPECTED OUTPUT

这是我到目前为止试过的 fiddle 。 JSFIDDLE

这是我的代码

HTML

<div class="width35 fll">
 <div class="mgl5">
 <div class="section month fll ng-binding">september</div></div>
  <div class="section day fs80 mgrt10 mgrt13 mgr30 osb fll ng-binding">03</div>
</div>

CSS

.width35 {
width: 35%;
}
.fll {
float: left;
}
.mgl5 {
margin-left: 5px;
}
.month {
-webkit-transform: rotate(-90deg) translate(-129%, 50%) !important;
    font-weight: bold;
font-family: arial;
font-size: 13px;
height: 85px;
width: 20px;
color: #CDCBCB;
}
.mgrt13 {
margin-top: -13px !important;
}
.osb {
font-family: open sans bold;
}
.mgr30 {
margin-right: 30px;
}
.mgrt13 {
margin-top: -13px !important;
}
.mgrt10 {
margin-top: -10px;
}
.fs80 {
font-size: 80px;
}
.day {
width: 68px;
height: 60px;
margin-right: 10px;
font-size: 60px;
font-weight: bold;
color: #A79C9C;
margin-left: -8px;
}
.section {
padding-bottom: 7px;
}

感谢任何帮助。

最佳答案

  *{
    box-sizing:border-box;
    padding:0;
    margin:0;
}

.example-date{
    color: #A79C9C;
    position:relative;
    border:1px solid #987;
    width:150px;
    height:150px;
    margin:40px auto;
    transform-style: preserve-3d;
    perspective: 960;
}
.example-day,.example-month{
    position:absolute;
}
.example-day{
    font-size: 150px;
    line-height:150px;
    right:-14px;
    top:50%;
    transform: translate3d(0,-50%,0);
}

.example-month{
    text-transform: uppercase;
    left: -50%;
    transform: rotate(-90deg) translate3d( -45%, 10px,0 );
    width: 100%;
    height: 20px;
    text-align: center;
    top: 0;
}
<div class="example-date">
    <div class="example-day">31</div> 
    <div class="example-month">september</div> 
</div>

关于javascript - 如何旋转以中心为中心的文本旋转到数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26102268/

相关文章:

javascript - 跳过 :first-child selector 上的隐藏元素

javascript - fs.readFile() 会在第一次读取后将文件内容缓存在服务器内存中吗?

javascript - 使用 React 路由器以编程方式导航

jquery - 更改位置媒体查询时引导 3 个动画列

javascript - FullPage JS onLeave

javascript - 在不重复 .mouseover() 函数的情况下迭代 div 组件

javascript - AWS 上的 Python 获取远程 IP 地址

css - 如何在不指定内部 div 高度的情况下在内部 div 周围放置一致的 5px 边距?

javascript - 如何在 DIV 的垂直列表上执行 "nowrap"

javascript - Bootstrap、contact_php 和 contact.js 不发送电子邮件