How to style a div like the button-element?

后端 未结 5 1539
南笙
南笙 2021-01-04 13:12

I\'ve noticed that when using the element, the browsers will naturally assume that you want to center the inline content, and that

5条回答
  •  天命终不由人
    2021-01-04 13:45

    You can center the content of a divby adding the same amount amount of padding on each side.

    padding:2px 10px;
    

    This adds 2px to the top and bottom and 10px to the left and right, thus centering the content in the div.

    I also styled the rest of the div to look and behave like a button. Looks are based on Firefox's default

提交回复
热议问题