i created a super simple html and css file to test display: inline-block, but when i test it there is some unwanted spaces between the boxes...
Html:
<!doctype html>
<head>
<title></title>
<meta charset="utf-8" />
<link href="Mall.css" rel="stylesheet" />
</head>
<body>
<div style="background-color:red;"></div>
<div style="background-color:blue;"></div>
<div style="background-color:green;"></div>
<div style="background-color:yellow;"></div>
</body>
</html>
CSS:
body {
padding: 0px;
margin: 0px;
width: 100%;
}
div {
display: inline-block;
margin: 0px;
padding: 0px;
width: 50px;
height: 50px;
}
I removed all paddings and margins from the div tags and the body tag, however when i run the html in chrome it produces this result: It is 3 pixels between the divs and 5 pixel beneth them so the total height of the body is 55 pixels when it should only be 50.
I have found a weird way to fix this which makes me think that this is an issue with the webbrowser and not the code, if i change the CSS to display: block
it will show my divs as normal in a diagonal line and whitout any weird spaces inbetween them.
Now if i open the developer tools in chrome and change the display in the style of one of the divs to inline-block they all line up horizantally and whitout any unwanted spaces.
Anyone have any idea why it behaves like this?