I would like to create a page header with a icon. However sometimes the page titles becomes too big and wrap to another line.
for now my result is:
but I would like to get this result (photoshoped)
Important! the icon must be aligned to the first line, like above picture.
Here is my HTML code:
<div class="page-header">
<div class="header-icon"><img src="to_do.png"></div>
<h1 class="page-title" >Não está em aula <small>2016-02-14 14:04</small></h1>
</div>
Here is my CSS
.page-header .header-icon{
display: inline-block;
vertical-align: middle;
padding-right: 10px;
}
.page-header .page-title{
display: inline;
vertical-align: middle;
}
2
Answers
The very simple answer (which some people will disapprove of) is to create a 2 column, 1 row table – the image goes in column one, the text in column two.
This way, any text overflow is catered for within column two – the separation between the image and the text is maintained.
I think this is a perfectly acceptable use of a simple presentational table when you have an image / text combination on one line (which happens often).
Whatever others say, this is the simplest way to do it.
You can define a bigger height for the icon. For this you have to add
float:left
and a fixed definedheight
in the.header-icon
class.For example like this:
Alternatively you can use
padding-bottom
for the.header-icon
class.