EN
CSS - negative margin
0
points
In this article, we would like to show you how to use negative margin in CSS.
Quick solution:
div {
margin: -10px;
}
Practical example
In this section, we present a practical example of how to use a negative margin on HTML page.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
body {
display: flex;
}
.container {
width: 100px;
height: 100px;
border: 1px solid black;
margin: 30px;
}
.negative-margin {
margin: -20px;
}
</style>
</head>
<body>
<div class="container">
<div class="negative-margin">Example text...</div>
</div>
<div class="container">
<div >Example text...</div>
</div>
</body>
</html>