css - 旋转文本并在 CSS 中对齐它?

标签 css

旋转然后将文本对齐到某些内容的一侧的首选解决方案是什么?

例子: http://jsfiddle.net/nVtpz/

<style>
.wrapper {
    width: 100px;
    height: 100px;
    border: 1px solid #009;
    margin: 50px;
}
.text
{
    border: 1px solid #900;
      -webkit-transform: rotate(-90deg);
     -moz-transform: rotate(-90deg);
      -ms-transform: rotate(-90deg);
       -o-transform: rotate(-90deg);
          transform: rotate(-90deg);

}
.image {
    border: 1px solid #090;
}
</style>

<div class="wrapper">    
    <div class="text">
        Text to rotate
    </div>
    <div class="image">
        <img src="http://lorempixel.com/100/100"/>
    </div>
</div>

我希望文本对齐到图像的左下角旁边(但不在图像顶部,即没有 float )

我想我可以使用 position: relative; bottom: 0px 或类似的东西,但有更好的方法吗?

最佳答案

I think that this is what you are going for ,但您可以使用 transform-origin 更改转换原点(根据需要使用相关的供应商前缀)。这是视情况而定,但在您的情况下:

transform: rotate(90deg) translateX(100%);
transform-origin: 100% 100%;

关于css - 旋转文本并在 CSS 中对齐它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16825561/

相关文章:

html - 如何在我的 html 中使用来自 Flaticon 的图标?

css - 如何使wordpress宽敞的主题全宽?

css - 背景附件效果:fixed but with img blocks and position

css - 在 Safari 6 中使用 CSS3 灰度滤镜进行对比度重载

css - 为什么我的 li 元素之间有空格?

css下划线两种颜色

html - 想要垂直对齐页面

javascript - 更改div样式时如何进行平滑更改

javascript - 根据窗口高度的百分比设置 CSS

html - HTML/CSS 中的下拉菜单实际上不是 "drop down"