Vertical center of DIV content, vertical center of div
Vertical-align: middle does not work on div. For example:
1 <! DOCTYPE html> 2
After running, the button is not vertically centered in the DIV:
Solution: If the width and height of the div and button are determined to be specific pixel values, you can directly set the css attribute of the button: position: relative; top (div. height-button. height)/2, left is (div. width-button.height)/2; otherwise add a div parent element to the button, the width and height are the same as the button, position is set to relative, both top and left are 50% (that is, the position in the upper left corner is set in the center of the outer div), and then the coordinates in the upper left corner of the button are set to-50% of the parent element div width and height (that is, the width and height of the button itself ).
The Code is as follows:
1 <! DOCTYPE html> 2
After re-running, the buttons in the div are displayed in the center
END