Issue
`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>```
Solution
try it :
.modal{
background: white;
width: 70%;
padding: 30px;
border-radius: 6px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 22px;
font-family: arial;
position: relative;
}
Answered By - zahramohamadi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.