0

I was create a div and another div inside of the div. I want these dot lines ... should be middle of the parent div (Horizontally and Vertically). Please help me. Thank you.

<div class = "test" style = "width: 32px; height: 22px; display: inline-block; border: 1px solid; border-radius: 5px; text-align: center;">
 <div style = "display: inline-block;">...</div>
</div>
Melbin Mathai
  • 487
  • 8
  • 26

2 Answers2

1

One possibility (and there are many) could be to use CSS Flexible Box Layout.

You can use the justify-content property to define aligment along the main axis and the align-items property to define how flex items are laid out along the cross axis.

You .test container would looks like this:

.test {
  display: flex;
  justify-content: center;
  align-items: center;
}

You can check an example on this JSFiddle.

HiDeoo
  • 10,353
  • 8
  • 47
  • 47
1

you have to use table-cell on your parent element and inline-block on the child and add vertical-align: middle to parent element:

<div class = "test" style = "width: 32px; height: 22px; display: table-cell; border: 1px solid; border-radius: 5px; text-align: center; vertical-align: middle;">
    <div style = "display: inline-block;">...</div>
</div>

https://jsfiddle.net/Lkfr6ar1/

Mustapha Larhrouch
  • 3,373
  • 3
  • 14
  • 28