Bonjour
je cherche a positionner plusieurs div les un par rapport au autre comme dans l'exemple de la fenêtre de chat de facebook quand vous ouvrer une nouvelle fenêtre elle se met a coté de la première automatiquement
je veux que a partir du deuxième div avec la class .main-chat il ajoute la largeur de son précédent a sa margin d'ou la formul calc()
voici le
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>FBlike</title>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/js/all.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
	<link rel="stylesheet" href="style.css">
</head>
<body>
 
	<div class="main" id="app">
		<div class="navbar">
			<div class="nav-bar-elements container">
				<div class="nav-bar-left-side">
					<div class="icon-home">
						<i class="fab fa-facebook-square"></i>	
					</div>
					<input type="text" class="search searchinput" placeholder=" Rechercher">
					<div class="btn search">
						<i class="fas fa-search"></i>
					</div>
				</div>
				<div class="nav-bar-right-side">
					<div class="icon-avatar">
		<img src="https://picsum.photos/23/23?random">
					</div>
					<a href="" class="lien">Bedji</a>
					<a href="" class="lien">Acceuil</a>
					<a href="" class="lien">Créer</a>
					<a href="" class="icon-button"><i class="fas fa-user-friends"></i></a>
					<a href="" class="icon-button"><i class="fab fa-facebook-messenger"></i></a>
					<a href="" class="icon-button"><i class="fas fa-bell"></i></a>
					<a href="" class="icon-button"><i class="fas fa-question-circle"></i></a>
					<a href="" class="icon-button"><i class="fas fa-caret-down"></i></a>
 
 
				</div>
 
			</div>
		</div>
		<div class="left-column container">
		<div class="member-id ">
 
				<img src="https://picsum.photos/23/23?random" alt="">
				<h4>Bedji Badrou</h4>
 
			</div>
			<div class="onglet active"><a href="" class="lien-left"><i class="far fa-newspaper"></i>Fil d'actualité</a></div>
 
			<onglet v-for="(item , id) in onglets"  :key="item.id"> </onglet>
 
			<div  class="onglet"><a href="" class="lien-left"><i class="fab fa-facebook-messenger"></i>Messenger</a></div>
 
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-tv"></i>Watch</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-store"></i>Marketplace</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-mosque"></i>Place</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-archway"></i>Paris</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-road"></i>Road</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-torii-gate"></i>Tours</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-campground"></i>Other</a></div>
			<div class="onglet"><a href="" class="lien-left"><i class="fas fa-dungeon"></i>Archives</a></div>
 
 
 
		</div>
		<div class="feed-column container">
 
			<div class="new-post">
					<div class="new-post-header">
						<div class="icon-avatar">
							<img src="https://picsum.photos/23/23?random=1">
						</div>
						<h4 class="id-name">nom d'utilisateur</h4>
						<div class="post-date">date:heure</div>
							<i class="fas fa-globe-africa"></i>
					</div>
 
					<p>
						{{message}}
					</p><img src="https://picsum.photos/500/300?random=2" alt="">
					<div class="button-side">
					<div class="button">
						<i class="far fa-thumbs-up"></i> Like
					</div>
					<div class="button">
						<i class="far fa-comment-alt"></i>Commenter
					</div>
					<div class="button">
						<i class="fas fa-share"></i> Partager 
					</div>	
					</div>
 
					<div class="comment-side">
						<div class="icon-avatar">
						<img src="https://picsum.photos/23/23?random">
					</div>
					<input type="text" class="comment">
					</div>
 
			</div>
			<div class="new-post">
					<div class="new-post-header">
						<div class="icon-avatar">
							<img src="https://picsum.photos/23/23?random=1">
						</div>
						<h4 class="id-name">nom d'utilisateur</h4>
						<div class="post-date">date:heure</div>
							<i class="fas fa-globe-africa"></i>
					</div>
					<p>{{ message }}</p><img src="https://picsum.photos/500/300?random=3" alt="">
					<div class="button-side">
					<div class="button">
						<i class="far fa-thumbs-up"></i> Like
					</div>
					<div class="button">
						<i class="far fa-comment-alt"></i>Commenter
					</div>
					<div class="button">
						<i class="fas fa-share"></i> Partager 
					</div>
					</div>
					<div class="comment-side">
					<div class="icon-avatar">
						<img src="https://picsum.photos/23/23?random">
					</div>
					<input type="text" class="comment">
				</div>
			</div>
 
 
		</div>
		<div class="footer-bloc ">
			<div class="footer-langages">
				<div class="langes">
				<a href="#" class="choisi">Francais (France)</a> 
				 <a href="#" class="">English (US) </a>  
				 <a href="#" class="">Espanol (Brasil)</a> 
				 <a href="#" class="">Deutsh (Allmagne)</a>	
				</div>
 
				<button>+</button>
			</div>
			<div class="footer-legal">
				 <a href="#">Confidentialité </a>
				 <a href="#">Conditions génerales</a>
				 <a href="#">publicité</a>
				 <a href="#">Choisir sa pub</a>
				 <a href="#">Cookies</a>
				 <a href="#" >Facebook @ 2020</a>
			</div>
		</div>
		<div class="contact-column" >
 
			<div v-for="user in contacts" :key="user.id" class="onglet-contact"><img :src="user.imgUrl" alt="" class="icon-avatar"><span :class="{enligne:user.enligne}">{{user.firstName}} {{user.lastName}}</span></div>
			<!-- <onglet-contact></onglet-contact> -->
 
 
			<div class="onglet-contact"><img src="https://picsum.photos/30/30?random=13" alt="" class="icon-avatar"><span class="enligne">Nom contact</span></div>
		</div>
 
 
	<div class="chat-main">
	<div class="chat-header">
		<div class="info-contact">
				<div class="icon-avatar"><img src="https://picsum.photos/32" alt=""></div>
					<h2 class="username">Nom contact</h2>
					<span class="contact-status">en ligne</span>
				</div>
		<div class="button-interaction">
				<i class="fas fa-video"></i>
				<i class="fas fa-phone"></i>
				<i class="fas fa-cog"></i>
				<i class="fas fa-times"></i>
		</div>								
	</div>	
		<div class="chat-message">
			<div class="msg-recive">
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo, animi!</p>
			</div>
			<div class="msg-sent">
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
			</div>
			<div class="msg-recive">
				<p>Numquam dolore sed perferendis, odit. Porro illo nemo expedita quae!</p>
			</div>
			<div class="msg-sent">
				<p>Dignissimos sunt, vitae iusto beatae eius nostrum, autem tempora ?</p>
			</div>
		</div>
		<div class="chat-input">
			<input type="text" placeholder="Enter votre message">
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
		</div>
	</div>
<!-- chat 2 -->
	<div v-if="chatvisible" class="chat-main">
	<div class="chat-header">
		<div class="info-contact">
				<div class="icon-avatar"><img src="https://picsum.photos/32" alt=""></div>
					<h2 class="username">Nom contact</h2>
					<span class="contact-status">en ligne</span>
				</div>
		<div class="button-interaction">
				<i class="fas fa-video"></i>
				<i class="fas fa-phone"></i>
				<i class="fas fa-cog"></i>
				<i @click="closechat" class="fas fa-times"></i>
		</div>								
	</div>	
		<div class="chat-message">
			<div class="msg-recive">
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo, animi!</p>
			</div>
			<div class="msg-sent">
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
			</div>
			<div class="msg-recive">
				<p>Numquam dolore sed perferendis, odit. Porro illo nemo expedita quae!</p>
			</div>
			<div class="msg-sent">
				<p>Dignissimos sunt, vitae iusto beatae eius nostrum, autem tempora ?</p>
			</div>
		</div>
		<div class="chat-input">
			<input type="text" placeholder="Entez votre message">
			<div class="chat-input-button">
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			<i class="fas fa-phone"></i>
			</div>
 
		</div>
	</div>
 
<!-- <chat-main></chat-main> -->
 
</div>
 
 
	<script src="app.js"></script>
</body>
</html>

voici le code css que j'ai utilisé
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
 
body{
	--chat-width:280px;
	--chat-right:55px;
	width:  
	box-sizing: border-box;
	padding:0;
	margin:0;
	background: #e9ebee;
	font-family: sans-serif;
}
.container {
	width: 1014px;
margin-left: 60px;
}
.navbar{
	height: 43px;
	background:#4267b2;
	position: fixed;
	z-index: 10;
	width: 100vw;
	top: 0;
}
.nav-bar-elements{
	justify-content: flex-start;
	align-content: center;
	display: flex;
	}
.nav-bar-left-side{
	/*padding: 10px 20px;*/
	display: flex;
	margin-right: auto;
}
.icon-home{
	color: white;
	font-size: 30px;
	margin: 5px 6px 5px 0px;
 
}
.icon-avatar img{
	border-radius: 50%;
}
.searchinput{
	height: 21px;
	margin: 10px auto;
	width: 400px;
	outline: none;
	border: #abadb3;
	border-bottom-left-radius: 2px;
	border-top-left-radius: 2px; 
}
 .btn{
 	background-color: #f5f6f7;
 	padding: 2px;
	height: 19px;
	margin: 10px auto;
	width: 45px;
	color: #4e5665;
	border-bottom-right-radius: 2px;
	border-top-right-radius: 2px; 
	text-align: center;
}
.nav-bar-right-side{
	justify-content: space-between;
	padding: 10px 0px;
	display: flex;
}
.nav-bar-right-side a{
	padding: 3px 10px;
	color: #fff;
	font-size: 13px;
	font-weight: bold;
	text-decoration: none;
}
.nav-bar-right-side .icon-button {
color: #1a2947;
font-size: 20px;
padding: 0px 9px;
	}
.nav-bar-right-side .icon-button:nth-child(3n+1)::after {
	content: '';
border-right: 1px #3b5ca0 solid;
padding-left: 10px;
}		
.nav-bar-right-side .lien {
 
padding-right: 4px ;
	}
	.nav-bar-right-side .lien::after {
 
content: '';
border-right: 1px #3b5ca0 solid;
padding-left: 10px;
	}
.left-column{
	padding: 5px 6px 5px 0;
	display: flex;
	flex-direction: column;
	width: 200px;
	font-size: 15px;
	height: 100vh;
	position: fixed;
top: 43px;
z-index: 9;
}
.member-id{
 
	display: flex;
	}
.member-id h4{
margin: 0;
font-weight: 200;
padding: 10px 5px 10px 0;
	}
.member-id img {
	margin-right:  5px;
	padding: 10px 0px 10px 0;
	border-radius: 50%;
	height: 23px;
	width:23px;
}
.active {
	border: 1px solid #e0e2e5;
	background-color: #f5f6f7;
	font-weight: bold;
	border-radius: 2px;
}
.onglet{
	padding: 5px 10px 5px 3px;
}
.onglet a{
	font-size: 13px;
	color: #000;
	text-decoration: none;
}
.onglet .svg-inline--fa{
	color: #01a4ff;
	margin-right:  5px;
	font-size: 18px;
}
.onglet:hover{
	background-color: #f5f6f7;
}
.feed-column{
	 margin-top: 43px; 
}
.new-post{
 
	margin-left: 210px;
	width: 500px;
	background: #fff;
	border:
	border: 1px solid #e0e2e5;
	border-radius: 2px; 
	margin-bottom: 13px; 
}
.new-post-header{
	padding: 9px 9px 0 9px;
	display: flex;
 
}
.new-post-header .icon-avatar img{
	width: 40px;
	height:40px;
}
.new-post-header h4{
	font-size: 15px;
	margin: 0;
	padding-left: 10px;
	color: #4267b2;
}
.new-post-header .post-date{
	align-self: flex-end;
	margin-left: -118px;
	font-size: 13px;
	color: #616770;
}
.new-post-header .svg-inline--fa{
	align-self: flex-end;
	padding-left: 10px;
	font-size: 13px;
	color: #616770;
 
}
.new-post p{
	padding: 0 10px;
}
.button-side{
	display: flex;
}
.button-side .button{
	box-sizing: border-box;
	width: 33%;
	display: block;
	text-align:  center;
	padding: 10px 0;
	color:#616770;
	cursor: pointer;
}
.button-side .svg-inline--fa{
	margin-right: 10px;
	font-size: 19px;
}
.comment{
	margin: 0 5px;
	background-color: #f2f3f5;
	height: 20px;
	padding: 5px;
	flex: 1;
	outline: none;
	border: 1px solid #d6d9dd;
	border-radius: 20px;
 
}
.comment-side{
	padding: 10px 0;
	align-content: center;
	justify-content: center;
	display: flex;
}
.comment-side img{
width: 30px;
margin-left: 9px;
}
.footer-bloc{
position: fixed;
top:63px;
left:785px;
width: 290px;
}
.footer-langages{
	padding: 15px;
	position: relative;
	display:flex; 
	border: 1px solid #e0e2e5;
	background-color: #fff;
	border-radius: 2px;
}
.footer-langages a{
	padding:0 5px;
	font-size: 13px;
	text-decoration: none;
	color: #4267b2;
}
.footer-langages a::after{
	content: ' . ';
}
a.choisi {
	text-decoration: none;
	color: #9197a3;
}
.footer-langages button{
	height: 30px;
	align-self: center;
	font-weight: 400;
	font-size: 20px;
	line-height :0px;
}
.footer-legal {
	font-size: 13px;
	padding: 10px 13px;
	display: inline-block;
}
.footer-legal a{
	color: #000;
	opacity: 0.4;
	text-decoration: none;
	font-weight: 500;
}
.footer-legal a:last-child {
	opacity: .7;
}
.footer-legal a::after{
	content: ' . ';
}
.contact-column{
	height: 100vh;
	position: fixed;
	right: 0;
	top: 43px;
 
	border-left: 1px ridge #d6d9dd;
}
.onglet-contact{
 
	display: flex;
	padding: 5px 10px ;
	align-content: center;
	transition: .6s;	
}
.onglet-contact:hover{
cursor: pointer;
background-color: #fff;
 
}
.onglet-contact img{
	border-radius: 50%;
}
.onglet-contact span{
	padding: 5px 5px;
font-size: 13px;
opacity: .7;
}
  span.enligne::after  {
	display: inline-block;
	content: '';
	width: 6px;
	height:6px;
	background-color: #42b72a;
	border-radius: 3px;
    margin-left: 50px;
}
 
.chat-main{
	background-color: #fff;
	position: fixed;
	bottom: 0;
	right:var(--chat-right) ;
	width: var(--chat-width);
	border-top-left-radius: 12px;
	border-top-right-radius: 12px;
	box-shadow: 0px 0px 5px 0px #8b8c8e;
	font-size: 12px;
}
.chat-main:nth-child(n+2) {
 
	--new-chat-right:calc(var(--chat-right) + var( --chat-width)); ;
	right: var(--new-chat-right);
	width: var(--chat-width);
 
}
/*.chat-main:nth-child(n+2){
	width: var(--chat-width);
	right:calc(var(--chat-right) + var( --chat-width));
}*/
.chat-header{
	padding: 10px 10px 2px 10px;
	display: flex;
	justify-content: space-between;
	border-bottom: 2px solid #e5e5e5;
}
.info-contact{
	display: flex;
	justify-content: flex-start;
}
.chat-header .username{
	font-size: 13px;
	padding: 1px 5px;
	margin: 1px 2px;
}
.contact-status{
	align-self: flex-end;
	color: #a497c1;
	left: 50px;
	position: absolute;
	top: 27px;
}
.button-interaction{
	color: #000;
	font-size: 18px;
	padding: 5px 5px;
	opacity: .3;
}
.button-interaction .svg-inline--fa{
	padding: 0 3px;
}
.chat-message{
	 overflow:scroll;
	overflow-x:hidden;
	height: 225px;
	border-bottom: 1px solid #e5e5e5;
}
.msg-recive{
	margin: 5px auto 9px 5px;
	background-color: #f1f0f0;
	padding: 1px 10px;
	border-radius: 15px;
	width: 70%;
}
.msg-sent{
 	margin: 5px 5px 9px auto;
	color: #fff;
	background-color: #0099ff;
	padding: 1px 10px;
	border-radius: 15px;
	width: 70%;
}
 
.chat-input{
	display: flex;
	flex-direction: column;
	}
.chat-input input{
	width: inherit;
	flex-grow: 0;
	padding: 8px 5px;
	outline: none;
	border: none;
}
.chat-input-button{
display: flex;
justify-content:space-evenly;
padding: 5px;
font-size: 20px;
opacity: .3;
}
et voici la partie qui pose probleme
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
body{
--chat-width:280px;
--chat-right:55px;
}
.chat-main{
	background-color: #fff;
	 position: fixed;
	 bottom: 0;
	right:var(--chat-right) ;
	width: var(--chat-width);
	border-top-left-radius: 12px;
	border-top-right-radius: 12px;
	box-shadow: 0px 0px 5px 0px #8b8c8e;
	font-size: 12px;
}
.chat-main:first-child {
	right: calc(var(--chat-right) + 190px);
	width: var(--chat-width);
}
.chat-main:nth-child(n+2){
	width: var(--chat-width);
	right:calc(var(--chat-right) + var( --chat-width));
}
le problème c'est que les fenêtres se mettent les un sur les autres
es-ce que j'ai mal utilisé calc ou c'est nth-child qui coince ?

Nom : Screenshot_2020-06-10 FBlike.png
Affichages : 130
Taille : 235,3 Ko

merci d'avance