How to style a div like the button-element?

后端 未结 5 1510
南笙
南笙 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:05

    http://jsfiddle.net/8Sj4A/3/ - this does center vertically and horizontally (just added text-align: center; to the originally answer)

    div {
        display:inline-block;
        color:#444;
        border:1px solid #CCC;
        background:#DDD;
        box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);
        cursor:pointer;
        vertical-align:middle;
        max-width: 100px;
        padding: 5px;
        text-align: center;
    }
    div:active {
        color:red;
        box-shadow: 0 0 5px -1px rgba(0,0,0,0.6);
    }
    

提交回复
热议问题