Answer the question
In order to leave comments, you need to log in
How can I position an object exactly in the center, regardless of the user's screen?
There is a code, simple 3 buttons, how to place them in the center of the screen?
<!DOCTYPE html>
<html lang="ru" dir="ltr">
<head>
<meta charset="utf-8">
<title>Brave tasks</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="btn-group-vertical" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Mansur05 , you provide an abstract example whose solution may not be a solution in another situation.
In the code you provided, the solution is as follows.
https://codepen.io/hisbvdis/pen/EqjvQb
try
body{
display: flex;
justify-content: center;
align-items: center;
}
or the second option:
.btn-group-vertical{
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
.btn-group-vertical {
position: absolute;
top: calc(50% - половина_высоты_блока);
left: calc(50% - половина_ширины_блока);
}
First way:
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.btn-group-vertical {
position: absolute;
top: calc(50% - 56px);
left: calc(50% - 38px);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question