Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 panel-title with header tag (h1) is not working

I'm using panels and I want the panel title to be larger. So I read the bootstrap doc for panel and saw that I could use a h1.panel-title inside a div.panel-header. They even give you the markup. I pasted the markup in my page with h1 and it did not work.

HTML:

<div class="panel panel-default">
  <div class="panel-heading">
    <h1 class="panel-title">Panel title</h1>
  </div>
  <div class="panel-body">
    Panel content
  </div>
</div>

Results:

enter image description here

I tried using the lead class, but it adds a lot of undesirable whitespace underneath it. If I exclude the panel-title class there is too much margin in the panel-header. How do I make this work?

like image 224
Jess Avatar asked Aug 28 '15 02:08

Jess


People also ask

What is a panel in Bootstrap?

A panel in bootstrap is a bordered box with some padding around its content: Panels are created with the .panel class, and content inside the panel has a .panel-body class: Example. The .panel-default class is used to style the color of the panel.

What are header components in Bootstrap 5?

Bootstrap 5 Header component Headers are compositions that extend standard navbar functionalities. They contain additional components like a jumbotron, sub-navbar, or image covers which serve as a containers for extra navigation elements - usually links, forms, or call-to-action buttons.

How do I add a heading box to a HTML panel?

You can optionally add a heading box to the panel. To do this, nest another <div> with a class of .panel-heading inside the .panel outer container. You can use normal text or you can place the heading text inside a <h1> - <h6> element with the .panel-title class applied.

What is the difference between Bootstrap 4 and bootstrap list groups?

Bootstrap list groups also integrate seamlessly into panels. Bootstrap 4 is discontinuing wells, thumbnails, and panels in favor of cards, which will do nearly everything wells, thumbnails, and panels did, only better. Bootstrap 4 is in alpha release at the time of writing.


1 Answers

New Answer

Thanks for the comment, @ShawnAnderson. You are absolutely right. All you need to do is remove the panel-title class and the h1 will work.

<div class="panel panel-default">
  <div class="panel-heading">
    <h1>Panel title</h1>
  </div>
  <div class="panel-body">
    Panel content
  </div>
</div>

Fiddle: https://jsfiddle.net/DTcHh/29507/

This answer is preferred over my original answer since you do not have to override any bootstrap classes.

Original Answer

This small amount of css will do the trick if you include it after bootstrap.css.

CSS:

h1.panel-title {
    font-size: 36px;
}
h2.panel-title {
    font-size: 30px;
}
h3.panel-title {
    font-size: 24px;
}
h4.panel-title {
    font-size: 18px
}
h5.panel-title {
    font-size: 14px
}
h6.panel-title {
    font-size: 10px;
} 

Results:

enter image description here

This works, but I'd like to know if anyone has better ideas.

like image 186
Jess Avatar answered Sep 21 '22 08:09

Jess