3
On another question I asked before, a user gave me an example of how I could perfectly centralize an html button on the screen.
It was in this question: How to position a button anywhere on the screen, in html
He simply did:
#centralizar{
position:absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%)
}
Only I tried to center three buttons below, starting from the same pattern, but it doesn’t work...
From what I saw in doc, Translate changes the position of an object on the screen from the multiplication of the object’s position matrix by a vector. In this case, I need to have the pixel position information in order to do this calculation, and have an idea of what the Translate value is, right? Or there’s an easier way.
Just follow my code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#centralizado1 {position:absolute; top=46%; left=50%; transform:translate(-46%, -50%)}
#centralizado2 {position:absolute; top=50%; left=50%; transform:translate(-50%, -50%)}
#centralizado3 {position:absolute; top=54%; left=50%; transform:translate(-54%, -50%)}
</style>
<body>
<div id="centralizado1">
<button >A</button>
</div>
<div id="centralizado2">
<button>B</button>
</div>
<div id="centralizado3">
<button>C</button
</div>
</body>
</html>
You invented a "=" in the statement that doesn’t exist. Read the existing documentation and examples in bulk - We are here to ask questions, but it is good to at least read the documentation, without trying "on the kick" and already ask.
– Bacco
I didn’t notice that. I was using two examples, and I didn’t notice the "equally instructive".
– Lucas Pletsch
Take advantage and add a size in an external div, to better see the effect. If you can solve it, you can publish the solution in the field below, so you can close the question. I even thought about posting an answer with the corrected code, but I’m not sure how the intended result is. An example of what you want (in image, for example, or a description of the result) would help.
– Bacco
Another problem appeared. Bou edit the question
– Lucas Pletsch
I published a more simplified basic model as a starting point.
– Bacco