`I have designed a project ,where a popup appears upon clicking a button,
but the problem is that the popup doesn’t appear in the center.
How can I solve this issue using CSS?
My HTML,CSS and JS code:`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>SabzLearn | Js | 165</title>
<link rel="stylesheet" href="test.css" />
</head>
<body>
<section>
<div class="center">
<h1>click the button below !</h1>
<button type="button">Click Here</button>
</div>
</section>
<div class="modal-parent">
<div class="modal">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum
dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ulorem lomre t labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
</p>
<span class="X">×</span>
</div>
</div>
<script src="test.js"></script>
</body>
</html>```
2
Answers
I would use flexbox:
try it :