go4*_*cas 6 html css css3 flexbox css-transforms
我正在尝试使用flexbox创建一个CSS小部件组件.
该组件有一个标题(应该有旋转的文本)和一个内容区域.
标题和内容都应填充父容器的高度,标题应为15px宽度,然后内容将拉伸以填充余数.
到目前为止,我得到的内容100%工作,但由于某种原因,标题没有填充父容器的高度.
到目前为止我有这个:
.widget {
height: 200px;
width: 200px;
border: 1px solid #ddd;
background-color: #eee;
display: flex;
}
.widget-header {
background-color: #1976D2;
color: #fff;
transform: rotate(-90deg);
border: 1px solid red;
font-size: 10px;
flex: 0;
height: 15px;
align-self: center;
text-align: center;
}
.widget-content {
border: 1px solid blue;
flex: 1;
}Run Code Online (Sandbox Code Playgroud)
<div class="widget">
<div class="widget-header">order summary</div>
<div class="widget-content">
<p>some text here</p>
<p>some more text ...</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
CodePen:http://codepen.io/go4cas/pen/XpryQR
旋转文本但不旋转更大的容器.标题的宽度为15px,指定的.
.widget {
height: 200px;
width: 200px;
border: 1px solid #ddd;
background-color: #eee;
display: flex;
}
.widget-header {
background-color: #1976d2;
flex: 0 0 15px;
min-width: 0;
display: flex;
justify-content: center;
align-items: center;
}
.widget-header > span {
color: #fff;
font-size: 10px;
transform: rotate(-90deg);
white-space: nowrap;
}
.widget-content {
border: 1px solid blue;
flex: 1;
}Run Code Online (Sandbox Code Playgroud)
<div class="widget">
<div class="widget-header">
<span>order summary</span>
</div>
<div class="widget-content">
<p>some text here</p>
<p>some more text ...</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
您将需要再添加一个环绕旋转文本。然后这个新插入的包装器应该被旋转,而不是弯曲的孩子。
HTML:
<div class="widget">
<div class="widget-header">
<div class="header-content">
order summary
</div>
</div>
<div class="widget-content">
<p>some text here</p>
<p>some more text ...</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
必要的CSS:
.widget {
position: relative;
display: flex;
}
.widget-header {
background-color: #1976D2;
border: 1px solid red;
text-align: center;
color: #fff;
width: 25px;
}
.header-content {
transform: rotate(-90deg);
transform-origin: 0 100%;
position: absolute;
line-height: 25px;
font-size: 14px;
height: 25px;
width: 100%;
left: 25px;
bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)
<div class="widget">
<div class="widget-header">
<div class="header-content">
order summary
</div>
</div>
<div class="widget-content">
<p>some text here</p>
<p>some more text ...</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.widget {
position: relative;
display: flex;
}
.widget-header {
background-color: #1976D2;
border: 1px solid red;
text-align: center;
color: #fff;
width: 25px;
}
.header-content {
transform: rotate(-90deg);
transform-origin: 0 100%;
position: absolute;
line-height: 25px;
font-size: 14px;
height: 25px;
width: 100%;
left: 25px;
bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)