According to the documentation, flex-basis: 200px
should set the initial size of the item to 200 pixels. However, I find that the initial size is some value between 160 and 170 that seems to depend on the browser, window width (even when it's wider than 200 pixels), and even the amount of margin on the other flexbox items.
<main style="display:flex">
<div style="flex-basis: 200px; background-color: #eee"></div>
<div style="flex-basis: 100%; background-color: #ccc"></div>
</main>
<style>
main, html, body {
position:absolute; top:0; left:0; right:0; bottom:0;
margin: 0;
}
</style>
<script>
for (div of document.getElementsByTagName("div"))
div.innerHTML = "WIDTH=" + div.offsetWidth;
</script>
Is there a reliable way to set the initial width of a flexbox item in pixels (assuming there is enough space for that many pixels)?