This example shows two boxes inside containers of 200px width. The first uses content-box, so the box is wider than the container and may overflow. The second uses border-box, so it fits perfectly inside the container.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Box Model Issues Example</title>
<style>
.container {
width: 200px;
background-color: #f0f0f0;
margin-bottom: 1rem;
}
.content-box {
width: 200px;
padding: 20px;
border: 5px solid #333;
box-sizing: content-box;
background-color: #cce5ff;
}
.border-box {
width: 200px;
padding: 20px;
border: 5px solid #333;
box-sizing: border-box;
background-color: #d4edda;
}
</style>
</head>
<body>
<section class="container">
<h2>Content-box (default)</h2>
<div class="content-box">Box with content-box sizing</div>
</section>
<section class="container">
<h2>Border-box</h2>
<div class="border-box">Box with border-box sizing</div>
</section>
</body>
</html>