Css problem with inline-block div

Hi guys


I'm developing a new website and I've found a strange behaviour with two inline-block divs. In all other browsers it works without problems.


The problem is that there is in safari a space above the first div and I can't understand why.

Here is the simple code:

<html>


<head>

<link rel='stylesheet' type='text/css' href='test.css'>

</head>


<body>


<div class='test'>



<div class='contactsColumn'>



<div id='A' class='alphabetLetter'>A</div>

<div id='B' class='alphabetLetter'>B</div>

<div id='C' class='alphabetLetter'>C</div>

<div id='D' class='alphabetLetter'>D</div>

<div id='E' class='alphabetLetter'>E</div>

<div id='F' class='alphabetLetter'>F</div>

<div id='G' class='alphabetLetter'>G</div>

<div id='H' class='alphabetLetter'>H</div>

<div id='I' class='alphabetLetter'>I</div>

<div id='J' class='alphabetLetter'>J</div>

<div id='K' class='alphabetLetter'>K</div>

<div id='L' class='alphabetLetter'>L</div>

<div id='M' class='alphabetLetter'>M</div>

<div id='N' class='alphabetLetter'>N</div>

<div id='O' class='alphabetLetter'>O</div>

<div id='P' class='alphabetLetter'>P</div>

<div id='R' class='alphabetLetter'>R</div>

<div id='S' class='alphabetLetter'>S</div>

<div id='T' class='alphabetLetter'>T</div>

<div id='U' class='alphabetLetter'>U</div>

<div id='V' class='alphabetLetter'>V</div>

<div id='W' class='alphabetLetter'>W</div>

<div id='X' class='alphabetLetter'>X</div>

<div id='Y' class='alphabetLetter'>Y</div>

<div id='Z' class='alphabetLetter'>Z</div>



</div><div class='contactDetails'>


</div>



</div>



</body>


.test {

background: red;

}



.contactsColumn {

width: 45%;

background: #ffffff;

overflow-y: auto;

height: 87%;

display: inline-block;

}



.alphabetLetter {

height: 20px;

background: #848484;

border: 1px solid #ffffff;

vertical-align: middle;

line-height: 20px;

color: #ffffff;

padding-left: 10px;

}



.contactDetails {

background: blue;

width: 54.9%;

height: 87%;

display: inline-block;

overflow-y: auto;

border-left: 1px solid #58B0F4;

}



Any suggestion?


Thanks in advance

The problem is that there is in safari a space above the first div and I can't understand why.

Use Web Inspector to find what's happening.


If you mean margins around body with `a space above the first div`, you should know every browser have default styles for each html elements.

In the latest Safari, `body` element have this style:

display: block;
margin-top: 8px;
margin-right: 8px;
margin-bottom: 8px;
margin-left: 8px;

These default styles may differ between implementations or versions of browsers, and you may need to add so-called `resetting.css` to make the difference smaller.

Try adding this to your .css:

body {
  margin: 0;
}


I may be missing your point, and if so, please try to describe your issue more presicely.

You haven't supplied enough to test bed your example, but so far, I don't see a space as you mention.


Which version Safari, on what platform, are you testing with? What flavor is the server?

I've shot a couple of images. This is in chrome:

http://i66.tinypic.com/18bx9c.png


and this is in safari:

http://i68.tinypic.com/116qn2p.png


as you can see, in safari there is a red space over the first div and simply it is the background color of the container div. In other words it seems that the first div is moved bottom by something. I've done some tests and I think the problem is caused by overflow-y: auto...


I'm using safari 9.0.3 on os x 10.11.3 and wildfly as application server.


Thanks

With your html and css both Safari and Chrome shows exactly the same result, which are different from both of your images.

Please show enough code to reproduce your issue.

The code I attached in my first post is the code that shows me the problem. Pay attention that the problem is visible only with the dev console closed

Of course, I checked the output while the dev console is closed. Have you tested your code with other brand new setup Macs?

No, I didn't 😟

I've also tried with ie edge and firefox and the problem affects only safari

Copy the html code (in your opening post) and save it as "test.html", copy the css code and save it as "test.css". And open "test.html" with Safari.

Is it the same as the png image "this is in safari:" ?

same problem.

Here you are:

http://i64.tinypic.com/11w6lg0.png

http://i65.tinypic.com/2j3o8z8.png

http://i63.tinypic.com/29268o7.png


Safari version: Versione 9.1 (11601.5.17.1)

With this experiment, one thing clear is that the problem hides in YOUR client side, not server side.

And I updated my system to work with Safari 9.1 and the result is nearly the same as what you have shown as Chrome output, just the background color filling the right side of the window is red, not blue.


By the way, I can see an unknown icon at the left end of the tab bar in your screen shot. Aren't you using some extensions in your Safari? Disable (or remove) all of them and see what happens.

Css problem with inline-block div
 
 
Q