Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Spacing and vertical alignment

Posted on 2014-03-20
5
Medium Priority
?
244 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
[X]
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
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

722 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