Skip to content

Instantly share code, notes, and snippets.

@lagenceoueb
Created March 21, 2022 11:08
Show Gist options
  • Save lagenceoueb/4381cf61b8fd2dcb751f736eb41e82ad to your computer and use it in GitHub Desktop.
Save lagenceoueb/4381cf61b8fd2dcb751f736eb41e82ad to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>My centered div wider than the parent div</title>
<style>
* {
box-sizing: border-box;
}
.parent {
max-width: 400px;
margin: 0 auto;
position: relative;
background-color: #ecbd33;
}
.child {
width: 100vw;
position: relative;
left: calc(-50vw + 50%);
height: 100px;
background-color: green;
}
</style>
</head>
<body>
<div class="parent">
<div class="child"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment