2

I know there is like 100 of topics made and I've tried all 100's of them and I just can't get it to work, Aligning the image in the middle, if you check in to

http://one1.no-ip.org/index.php?hitta=tanto&page=search

you'll see that the logo is at the top of the screen and whatever I do I just can't make it align correctly. I'm sure something is interfering but I just can't find out what, I even made a fiddle to check if the method im using is working and it is

http://jsfiddle.net/UJATF/ Working example with the image in the middle of the div element

CSS

 .logo{ background:white; position:absolute; width:105px; height:90px; line-height:90px; left:180px; margin-top:20px; line-height:90px; text-align:center; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow:inset 0px 0px 0px 1px white,inset 0px 0px 10px -4px black; z-index:1000; overflow:hidden; } .logo img{ vertical-align:middle; max-width:90px; max-height:40px; } 

HTML

<div class="logo"> <a href="./index.php?page=profile&amp;id=377948"><img src="http://www.tantobil.se/images/logo.png"></a> </div> 

so all help would be very much appreciated

6
  • 1
    post the desired result screenshot Commented Nov 29, 2012 at 10:53
  • Also have you tried firebug or chrome developer tools as you can see exactly what is inherited and what is blocking you Commented Nov 29, 2012 at 10:54
  • where you want the logo to be placed..?? Commented Nov 29, 2012 at 10:54
  • i want the image to be align in the middle like the fiddle shows, but I havent been able to achive Commented Nov 29, 2012 at 10:54
  • @pengibot Yes I've tried it and couldnt find anything that should interfere, but something still does... Haven't figured it out Commented Nov 29, 2012 at 10:55

2 Answers 2

1

Define your anchor link display : inline-block and give to margin-top

as like this

.logo > a { display: inline-block; margin-top: 22px; } 

Results is

enter image description here

--------

Is your are using dynamic with of img than used to this Second option is

.logo > a { display: table-cell; height: 90px; text-align: center; vertical-align: middle; width: 105px; } 
Sign up to request clarification or add additional context in comments.

6 Comments

the logo can Have diffrent sizes
According to logo height define to margin top
This is the same result I'm seeing anyway.
Check to my updated answer if your logo is put to the dynamic than used to this .logo > a { display: table-cell; height: 90px; text-align: center; vertical-align: middle; width: 105px; }
@RohitAzad Still curious though why the other one didnt, work on the site but worked on jsfiddle =/
|
0

Since you're using fixed heights in your css, why don't you just use simple math to determine the top position of the logo?

.content is 121px high, .logo is 90px high

The difference is 31px, which means you need a top offset of 15.5px Also, set the .content to position: relative so you position the logo relatively to .content's top.

2 Comments

Cause the image can have diffrent sizes
Ah, I didn't get that because you use a fixed height on it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.