Skip to content

Instantly share code, notes, and snippets.

@tiendq
Created July 31, 2013 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tiendq/6119201 to your computer and use it in GitHub Desktop.
Save tiendq/6119201 to your computer and use it in GitHub Desktop.
How to fight inline blocks space and heigh 100%
<!doctype html>
<html>
<head>
<style>
.parent {
width: 600px;
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: yellow;
}
.child {
display: inline-block;
width: 200px;
background-color: green;
}
.child-margin {
display: inline-block;
width: 200px;
background-color: green;
margin-left: -0.25em;
}
.child-margin:first-of-type {
margin-left: 0;
}
html, body, .container {
height: 100%;
margin: 0;
padding: 0;
}
.container {
background-color: #ccc;
}
</style>
</head>
<body>
<div class="container">
<!-- fixing inline block space http://tympanus.net/codrops/2013/07/17/troubleshooting-css/ -->
<div class="parent">
<div class="child">I'm a child!</div><!--
--><div class="child">I'm a child!</div><!--
--><div class="child">I'm a child!</div>
</div>
<br />
<div class="parent">
<div class="child-margin">I'm a child!</div>
<div class="child-margin">I'm a child!</div>
<div class="child-margin">I'm a child!</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment