我有一个自举面板,我将标题移到了左侧.我正在努力使文本垂直(旋转90度).
我在大多数情况下都有这个,但是我在使用其他东西与CSS保持一致时遇到了一些麻烦.
我的最终目标是图标出现在标题/子标题之前,所有内容都在面板标题中居中,子标题位于标题下方.
.panel {
position: relative;
}
.panel-default>.panel-leftheading {
color: #333;
background-color: #f5f5f5;
border-color: #ddd;
}
.panel-primary>.panel-leftheading {
color: #fff;
background-color: #428bca;
border-color: #428bca;
}
.panel-success>.panel-leftheading {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}
.panel-info>.panel-leftheading {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
}
.panel-warning>.panel-leftheading {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
}
.panel-danger>.panel-leftheading {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.panel-leftheading {
width: 42px;
padding-top: 10px;
padding-right: 15px;
padding-bottom: 10px;
padding-left: 8px;
border-right: 1px solid transparent;
border-bottom: 1px solid transparent;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
float: left;
height: 100%;
}
.panel-lefttitle {
margin-top: 110px;
margin-bottom: 0;
font-size: 12px;
color: inherit;
-webkit-transform: rotate(-90deg);
-webkit-transform-origin: left top;
-moz-transform: rotate(-90deg);
-moz-transform-origin: left top;
-ms-transform: rotate(-90deg);
-ms-transform-origin: left top;
-o-transform: rotate(-90deg);
-o-transform-origin: left top;
transform: rotate(-90deg);
transform-origin: left top;
white-space: nowrap;
}
.panel-rightbody {
margin-left: 50px;
height: 100%;
}
.mainTitle {
font-style: bold;
font-size: 14px;
}
.subTitle {
font-style: italic;
}
我尝试了所有我知道的对齐属性(text-align,align-content等),但它们似乎没有像我预期的那样调整div中的内容.
如何在保持文本左侧的图标的同时将内容与中间对齐?
(JS小提琴:http://jsfiddle.net/jbk075c8/2/)
最终目标:
最佳答案
您应该能够使用display:flex |的组合flex-inline和float来实现这一点.这是一个例子:
原文链接:https://www.f2er.com/html/426289.html.panel {
position: relative;
}
.panel-default>.panel-leftheading {
color: #333;
background-color: #f5f5f5;
border-color: #ddd;
}
.panel-primary>.panel-leftheading {
color: #fff;
background-color: #428bca;
border-color: #428bca;
}
.panel-success>.panel-leftheading {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}
.panel-info>.panel-leftheading {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
}
.panel-warning>.panel-leftheading {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
}
.panel-danger>.panel-leftheading {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.panel-leftheading {
width: 42px;
padding-top: 10px;
padding-right: 15px;
padding-bottom: 10px;
padding-left: 8px;
border-right: 1px solid transparent;
border-bottom: 1px solid transparent;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
float: left;
height: 100%;
display: inline-flex;
}
.panel-lefttitle {
margin-top: 150px;
margin-bottom: 0;
font-size: 12px;
color: inherit;
-webkit-transform: rotate(-90deg);
-webkit-transform-origin: left top;
-moz-transform: rotate(-90deg);
-moz-transform-origin: left top;
-ms-transform: rotate(-90deg);
-ms-transform-origin: left top;
-o-transform: rotate(-90deg);
-o-transform-origin: left top;
transform: rotate(-90deg);
transform-origin: left top;
white-space: nowrap;
}
.panel-lefttitle i {
margin-bottom: 20px;
margin-right: 10px;
}
.panel-rightbody {
margin-left: 50px;
height: 100%;
}
.mainTitle {
display: block;
font-style: bold;
font-size: 14px;
}
.subTitle {
font-style: italic;
}
.titleWrapper {
text-align: center;
}
如果这有助于您,请告诉我.