我不确定是否有另一种方法可以在不使用绝对定位的情况下获得此布局。
titleAdd__text
类的宽度固定为4rem
,但我希望根据内容进行更改而不是修复。我该怎么做呢?
body {
background-color: #fff;
}
.titleBody {
overflow-x: hidden;
overflow-y: auto;
height: 200px;
}
.titleAdd {
background-color: #f4f4f4;
min-height: 4rem;
position: relative;
}
.titleAdd__plus {
border-bottom: 2px solid #fff;
}
.titleAdd__plus:hover {
background-color: #eee;
}
.titleAdd__text {
min-width: 4rem;
position: absolute;
text-align: center;
-moz-transform: rotate(-90deg) translate(-100%, 0%);
-webkit-transform: rotate(-90deg) translate(-100%, 0%);
-o-transform: rotate(-90deg) translate(-100%, 0%);
-ms-transform: rotate(-90deg) translate(-100%, 0%);
transform: rotate(-90deg) translate(-100%, 0%);
-ms-transform-origin: left top;
-webkit-transform-origin: left top;
transform-origin: left top;
font-family: 'Titillium Web', serif;
letter-spacing: 0.05em;
background-color: #2dc8ff;
color: #fff;
font-size: 0.9rem;
}
.titleAdd__body {
padding-left: 2rem;
font-size: 0.9rem;
line-height: 1.5rem;
cursor: pointer;
height: 4rem;
display: table-cell;
vertical-align: middle;
}

<div class="titleBody">
<div class="titleAdd">
<div class="titleAdd__plus">
<div class="titleAdd__text">Add</div>
<div class="titleAdd__body">Overview the processes of the company functioning</div>
</div>
<div class="titleAdd__plus">
<div class="titleAdd__text">Add</div>
<div class="titleAdd__body">Implemented multiple predictive models and clustering to cross-sell high profit LAP (loan against property) to current clients. Implemented multiple predictive models and clustering to cross-sell high profit LAP (loan against property) to current
clients. Implemented multiple predictive models and clustering to cross-sell high profit LAP to current clients. </div>
</div>
<div class="titleAdd__plus">
<div class="titleAdd__text">Add</div>
<div class="titleAdd__body">Enterprise grade machine learning platform for auto-updating. Enterprise grade machine learning platform for auto-updating. Enterprise grade machine learning platform for auto-updating. </div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:2)
您必须使用titleAdd__text
和top:0
作为绝对bottom:0
- 这将为您提供蓝色div与父级相同的高度与位置相对(添加相对于{{的位置) 1}})。然后,您必须在内部使用文本titleAdd__plus
旋转范围,而不是整个div并删除Add
http://jsfiddle.net/b5vx7q63/2/
看起来很棒。谢谢。这是一个最后的小问题:titleAdd__text中的text-align:center不再有效。知道如何去做吗?
我发现有transform-origin
。我用writing-mode
text