Skip to content

Instantly share code, notes, and snippets.

@ehzhang
Last active April 25, 2017 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehzhang/fd6cf7948dd3be82675f518ba0cb0dcd to your computer and use it in GitHub Desktop.
Save ehzhang/fd6cf7948dd3be82675f518ba0cb0dcd to your computer and use it in GitHub Desktop.
prince box-sizing padding/border bug.
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.item {
width: 20px;
height: 20px;
position: relative;
}
.border-workaround {
position: absolute;
top: 0;
left: 0;
border: 4px solid black;
width: 20px;
height: 20px;
}
.container {
display: inline-block;
padding-left: 20px;
padding-right: 20px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="container">
<div class="item">
<div class="border-workaround">
</div>
</div>
</div>
</body>
</html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.item {
width: 20px;
height: 20px;
border: 5px solid black;
}
.container {
display: inline-block;
padding-left: 20px;
padding-right: 20px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="container">
<div class="item"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment