How to style a div like the button-element?

后端 未结 5 1550
南笙
南笙 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 14:06

    css:

    div.button {
      display:inline-block;
      -webkit-appearance:button;
      padding:3px 8px 3px 8px;
      font-size:13px;
      position:relative;
      cursor:context-menu;
    }
    

    html:

    Press Me!

    This gets you as close as I could get to a real button.

    For anything other than Chrome: look up appearance. Actually, just use Chrome... :)

提交回复
热议问题