iGyan.Org iGyan.Org - 3 months ago 16
CSS Question

Vertical bootstrap panel header

I am trying to design the vertical bootstrap header panel, and I have almost achieved it using this



.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: 10px 15px;
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%;
position: absolute;
}

.panel-lefttitle
{
margin-top: 0;
margin-bottom: 0;
margin-left: 15px;
font-size: 16px;
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;
position: absolute;
white-space: nowrap;
}

.panel-rightbody
{
float: left;
margin-left: 45px;
padding: 15px;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="page-header">
</div>
<div class="row">
<div class="col-md-6">

<div class="panel panel-primary">
<div class="panel-leftheading">
<h3 class="panel-lefttitle">Panel title</h3>
</div>
<div class="panel-rightbody">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>
<div class="clearfix">
</div>
</div>

</div>
</div>





Now the header is set to the vertical but the font alignment is not as expected. the font on the header should be readable and must be horizontal like this image

vertical Panel Bootstrap

what css I need to change?

Answer

You can remove the transforms and the margin-left and add a width (set as 0 here) smaller than the font-size(16px here) to the get the effect:

.panel-lefttitle {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 16px;
  color: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: center;
  width: 0;
}

Also note have added in word-wrap: break-word and white-space: pre-wrap for the text to flow vertically preserving whitespaces / line-breaks.

.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: 10px 15px;
  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%;
  position: absolute;
}
.panel-lefttitle {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 16px;
  color: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: center;
  width: 0;
}
.panel-rightbody {
  float: left;
  margin-left: 45px;
  padding: 15px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="page-header">
  </div>
  <div class="row">
    <div class="col-md-6">

      <div class="panel panel-primary">
        <div class="panel-leftheading">
          <h3 class="panel-lefttitle">Panel title</h3>
        </div>
        <div class="panel-rightbody">
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

        </div>
        <div class="clearfix">
        </div>
      </div>

    </div>
  </div>

Let me know your feedback on this. Thanks!

Comments