Here is what I am trying
I have an element in the center that i want to stay in the center. Now i want an element to hug the left side of this element.
so in reality where i want the left most position of the left div would be right:calc(50%-200px-(lefts width));
my problem is doing right:50%; does something but right:calc(50% +100px) does not.
How can i make it so the div with the left class is always hugging the guy in the center?
<div class="left"> hug this center element </div>
<div class="middle"> this stays in the middle</div>
calc() The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a <length> , <frequency> , <angle> , <time> , <percentage> , <number> , or <integer> is allowed.
To just center the text inside an element, use text-align: center; This text is centered.
Like last time, you must know the width and height of the element you want to center. Set the position property of the parent element to relative . Then set the child's position property to absolute , top to 50% , and left to 50% . This just centers the top left corner of the child element vertically and horizontally.
left: 50%; //-> align center
margin-left: -30px; //-> your element width / 2 when element = 60px
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With