Whenever i want to make a html page i have problem with this, why html page is less than 100%? Let me explain in example:
You can float
the divs
instead of using inline-block
to get the effect you want.
html, body
{
margin: 0;
padding: 0;
width: 100%;
}
.row
{
width: 100%;
margin: 0;
padding: 0;
}
.col-1
{
width: 10%;
margin: 0;
padding: 0;
float: left;
}
<body>
<div class="row">
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
<div class="col-1">Some text</div>
</div>
</body>
It is because display:inline-block
creates white-space in the html...
you could change the display:inline-block
to float:left
see https://jsfiddle.net/z0cc6fp7/1/
When you give display: inline-block;
it generates spaces in-between them. Use the same code this way:
<div class="row">
<div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div><!--
--><div class="col-1">Some text</div>
</div>
Fiddle: http://output.jsbin.com/xorahifipe
You can also use float: left
, but you need to give overflow: hidden;
to the parent, or clear it somehow. With your original example, float
works this way:
.row {
width: 100%; /* This is not necessary */
margin: 0 auto; /* This is not necessary */
padding: 0; /* This is not necessary */
overflow: hidden;
}
.col-1 {
width: 10%;
margin: 0; /* This is not necessary */
padding: 0; /* This is not necessary */
float: left;
}
Fiddle: http://output.jsbin.com/daruzepiqa/1