Reputation: 10609
I have the following HTML header. It's a simple title bar with a back href.
However the headline <h1>
is placed UNDER the href. I don't want that.
What I want is a simple title bar with a centered headline and a button
which is on the same height like the headline.
html,
body {
height: 100%;
margin: 0;
background-color: #EEEEEE;
font-family: 'RobotoDraft', 'sans-serif';
}
header {
background: #FFFFFF;
height: 60px;
width: 100%;
box-shadow: 0px 2px 1px #888888;
margin: 0;
padding: 0;
overflow: hidden;
}
h1 {
color: black;
text-align: center;
padding: 15px 0;
margin: 0;
font-size: 30px;
}
<header>
<a href="#">Back</a>
<h1>Photo Framed</h1>
</header>
How can i achieve that?
This is what it looks like now:
Since I'm very new to the world of HTML and CSS, I have no clue how to not let the title get pushed down by the back href. Later I want to replace the href by an image. It should be the same with the image. I have a padding of 15px for the title. I also want 15px padding for the back href and want it to be on the same height like the title.
Upvotes: 1
Views: 47
Reputation: 78786
You could set a line-height
and make the value the same as the h1
's height.
a {
float: left;
line-height: 60px;
}
Or use absolute position
instead of float
, and combine with the line-height
.
a {
position: absolute;
left: 0;
top: 0;
line-height: 60px;
}
http://jsfiddle.net/epxhnohr/1/
Upvotes: 2
Reputation: 1791
Try this...http://jsfiddle.net/devkickstart/Lcy2kf0j/
header{
height: 40px;
}
header *{
line-height: 40px;
}
a{
float: left;
}
h1{
text-align: center;
}
Upvotes: 0