Move the image to the right plus...

User 1946084 Photo


Registered User
29 posts

Hi All,

Newbie here..... knows enough to break things :-)

Im using an existing HTML Template. I've made some changes to include a banner and remove the existing header layout.

Now in the header I have 2 images. i need to move the second "red" image to the right to align with the Navigation below it.

Here is the current code

<body>
<div id="header">
<div class="container">
<h1 id="logo"></h1><img src="images/Banner2.png" width="710" height="115" alt="" title="" border="0" align="" />
<img src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />
<form action="#" method="post">
<input type="text" name="keyword" id="keyword" />
<input type="button" value="Search" id="s" />
</form>
</div>
</div> <!-- /#header -->


I have attached a screenshot showing how this currently displays.

Also, how can I remove or shrink the spacing between the Header (green line across the top) and the new banner as well as the spacing below the banner and the image? Ive played around in the styles.css but cant seem to get it.

Thanks in advance.
Glenn

Attachments:
User 1946084 Photo


Registered User
29 posts

First issue sorted using

&nbsp


too easy

Still working on the second issue
User 184085 Photo


Ambassador
1,707 posts

try

<img style="float:right; margin-right:0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />


tweak the padding value to get the alignment.

should work... :D
Volunteering to help :)
http://www.tbaygeek.ca
My HTML play area
http://www.tbaygeek.ca/test/
User 117361 Photo


Ambassador
6,076 posts

See if there are any margins or padding set up for the new banner. If not you might have to add in some new margin banners for the top image. In David's snippet of code there is only one for the margin-right as follows.

<img style="float:right; margin-right:0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />


Try this maybe:
<img style="float:right; margin:0px 0px 0px 0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />


Now you can experiment with those 4 different margin values bearing in mind that they refer to the top, right, bottom and left reading left to right. You can even try using a minus value for the bottom to bring the two images closer to one another.

eg.
<img style="float:right; margin:0px 0px -10px 0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />

See how this works for you. It might even mean that you can remove that no-break space you used earlier
&nbsp
User 1946084 Photo


Registered User
29 posts

David and Janys,

Thanks so much for that. This stuff can do your head in.

I tried all the options and decided to use Janys' option with the margin and apply it to both images.

<div id="header">
<div class="container">
<h1 id="logo"></h1><img style="float:left; margin:0px 0px 0px 0px; padding-left:0px;" src="images/Banner2.png" width="710" height="115" alt="" title="" border="0" align="" /><img style="float:right; margin:0px 0px 0px 0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />
<form action="#" method="post">
<input type="text" name="keyword" id="keyword" />
<input type="button" value="Search" id="s" />
</form>
</div>
</div> <!-- /#header -->


I also changed the styles.css for the header to this

#header {
background:#fff;
border-top:5px solid #66cb31;
margin:0 auto;
padding:10px;
width:940px;


previously the width was set to 920. Changing it to 940 removed the extra padding.

When I preview it, it looks perfect. However when I open in browser the bottom 3/4s of both images is cut off, just leaving a white or blank space?

Any ideas?

User 117361 Photo


Ambassador
6,076 posts

Somewhere you must have declared the height of the space where the image is which now needs to be changed to take into account the amount of margin/padding you have. Try changing by the same amount and that should fix it... that is... add the amount you have used as the margin (and/or the padding) to the height.
User 1946084 Photo


Registered User
29 posts

Thanks again Janys

To try and troubleshoot this what I did was take it back to standard image display. This showed both the images side by side, but not aligned correctly.

Then I added the code with the margin

from this

<img src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />

to this


<img style="float:right; margin:0px 0px -10px 0px; padding-right:0px;" src="images/Image Template.png" width="220" height="115" alt="" title="" border="0" align="" />


Does that code that you provided add any margin value or padding by default? I have all my margins set to 0, but it seems to have added margin by 10 in places?

Almost over it. Just about to log a support ticket.

User 1946084 Photo


Registered User
29 posts

All sorted.

I went back to the &nbsp and its all good :-)

Thanks again
User 117361 Photo


Ambassador
6,076 posts

You mustn't forget that if you add 5 at the top and 5 at the bottom, in some places that will become doubled up because you have, let's say, 2 images, side by side or above one another, each with 5 all around.

If there are default settings (as can be the case) they may be coming from an application or similar which already has some margins set up. I advise you to get a pixel ruler to use on your desktop. Great for checking out measurements without having to delve into code.

Here is one for instance:
http://www.mioplanet.com/products/pixelruler/
I think I saw something similar for a firefox addon the other day too.
User 133269 Photo


Registered User
2,900 posts

you could try a display:block in the style bit on your image tag - that might cut out the difference between image default margin or none....

perhaps also remove the align="" from the end of the image tag
Have fun
~ Fe Pixie ~

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.