How to properly style a text area with inner shadows and scrollbar

前端 未结 4 1819
生来不讨喜
生来不讨喜 2021-01-31 18:19

I\'m putting an inner-shadow on all my controls, inputs and textareas by using the following CSS:

input {
  padding: 7px;
  -webkit-box-shadow: inset 2px 2px 2px         


        
4条回答
  •  清歌不尽
    2021-01-31 18:40

    Getting the padding property to affect only the content but not the scrollbar is not possible using standard textarea elements. For that you can use a contenteditable DIV. For example, check this fiddle: http://jsfiddle.net/AQjN7/

    HTML:

    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

    CSS:

    .outer {
        -webkit-box-shadow: inset 2px 2px 2px 0px #ffffdffffd;
        -moz-box-shadow: inset 2px 2px 2px 0px #ffffdffffd;
        box-shadow: inset 2px 2px 2px 0px #ffffdffffd;
        height: 200px;
        margin: 10px;
        overflow: auto;
        padding: 7px 10px;
        width: 300px;    
        font-family: tahoma;
        font-size: 13px;
        border: 1px solid #aaa;
    }
    ​
    

提交回复
热议问题