EN
CSS - negative margin
0 points
In this article, we would like to show you how to use negative margin in CSS.
Quick solution:
xxxxxxxxxx
1
div {
2
margin: -10px;
3
}
In this section, we present a practical example of how to use a negative margin on HTML page.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
body {
6
display: flex;
7
}
8
9
.container {
10
width: 100px;
11
height: 100px;
12
border: 1px solid black;
13
margin: 30px;
14
}
15
16
.negative-margin {
17
margin: -20px;
18
}
19
20
</style>
21
</head>
22
<body>
23
<div class="container">
24
<div class="negative-margin">Example text...</div>
25
</div>
26
<div class="container">
27
<div >Example text...</div>
28
</div>
29
</body>
30
</html>