Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Spacing and vertical alignment

Posted on 2014-03-20
5
239 Views
Last Modified: 2014-03-21
How can I get rid of the space between the header and head-banner div tags and how can I align the img and the text that sit in the head-banner div. Thank you.


<!DOCTYPE html>
<html charset="UTF-8">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Test</title>
	<link rel="stylesheet" type="text/css" href="styles/styles.css" />	

	<!--[if lt IE 7]>
		<style type="text/css">
			#wrapper { height:100%; }
		</style>
	<![endif]-->
	
</head>

<body>

	<div id="wrapper">
		
		<div id="header">
		</div><!-- #header -->
		
		<div id="head-banner">
			<p>
			<img src="imgs/kevinbarlow.png" />
			Building Contractor
			Key West, Florida</p>
		</div>
		
		<div id="content">
		</div><!-- #content -->
		
		<div id="footer">
		</div><!-- #footer -->
		
	</div><!-- #wrapper -->
	
</body>

</html>

Open in new window


html,
body {
	margin:0;
	padding:0;
	height:100%;
}
html{
	background: url(S12_Blueprints.gif) no-repeat center center fixed;
	-webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
#wrapper {
	min-height:100%;
	width: 100%;
	position:relative;
}
#header {
	background:#000000;
	padding:10px;
	border-bottom: 2px solid red;
}
#head-banner{
	height: 75px;
	max-width: inherit;
	margin-top: 0;
	margin-bottom: 0;
	background-color: #ffffff;
}
#head-banner img p{
	display: inline-block;
	vertical-align: middle;
}
#content {
	min-width: 100%;
	height: 500px;
	border: 1px solid black;
}

#footer {
	background:#ffab62;
	width:100%;
	height:100px;
	position:absolute;
	bottom:0;
	left:0;
	border: 1px solid black;
}

Open in new window

0
Comment
Question by:centem
5 Comments
 
LVL 5

Expert Comment

by:jayakrishnabh
ID: 39941884
To remove space between header and header-banner make padding as 0px for the header style

#header {
            background:#000000;
            padding:0px;
            border-bottom: 2px solid red;
      }
0
 

Author Comment

by:centem
ID: 39941943
Thanks jayakrishnabh but that didn't work. The issue seems to be with margin spacing between the two tags. I tried setting the margin to 0 but that didn't seem to work either.
0
 
LVL 4

Accepted Solution

by:
slfede earned 500 total points
ID: 39941989
To remove the spacing between the header and head-banner divs, simply either:

- remove the p tag from head-banner div

- edit this css

This is incorrect, your p tag comes before the img tag.
#head-banner img p{
	display: inline-block;
	vertical-align: middle;
}

Open in new window


It should be this:

#head-banner p{
    display: inline-block;
    vertical-align:middle;
    margin-top:0;
}

Open in new window


If you want to center align it:

#head-banner{
	height: 75px;
        width:100%;
        text-align:center;
	margin-top: 0;
	margin-bottom: 0;
	background-color: #ffffff;
}

Open in new window


http://jsfiddle.net/cTGLS/
0
 

Author Comment

by:centem
ID: 39942077
Thanks slfede,
I'm trying to align the text vertically with the img.  I tried the below css but it does not align it.
 
#head-banner p{
	display: inline-block;
	vertical-align: middle;
	margin-top: 0;
}

Open in new window

0
 
LVL 10

Expert Comment

by:jtwcs
ID: 39943108
The spacing is being caused by the browser default margins being applied to the <p>.  Look into using a css reset to start off with a good baseline.

The text can be vertically aligned to the middle of the image by styling the <img> with a vertical-align: middle declaration.

See here for full example.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question