html
< div class = "message-ly" >
< div class = "message-ly-mask" > < /div>
< div class = "say-box" data-slide-in= "at 3000 from zoomIn use linear during 2000" >
< i class = "message-ly-close" > < /i>
< div class = "message-ly-header" >
< span class = "message-ly-close" > 取消< /span>
< span class = "message-ly-tit" > 我的留言< /span>
< button id = "save" type = "button" > 发出< /button>
< /div>
< div class = "textarea" currentlength = "0" maxlength = "80" >
< textarea name = "liuyan" placeholder = "回首山大的生活,你是否有话想说?" maxlength = "80" > < /textarea>
< /div>
< /div>
< /div>
css
.message-ly {
position: absolute;
top: 0 ;
left: 0 ;
z-index: 7 ;
width: 100 %;
height: 100 %;
display: none;
}
.message-ly-mask {
height: 100 %;
width: 100 %;
background-color: rgba( 0 , 0 , 0 , 0.6 ) ;
}
.say-box {
width: 100 %;
height: 55 %;
position: absolute;
bottom: 0 ;
left: 0 ;
z-index: 8 ;
background-color:
}
.say-box::before {
content: '' ;
width: 0 .28rem;
height: 0 .28rem;
display: inline-block;
position: absolute;
left: 0 .2rem;
top: 0 .5rem;
z-index: 1 ;
}
.message-ly-close {
font-size: 0 .32rem;
color:
z-index: 9 ;
display: inline-block;
width: 25 %;
margin-left: 0 .5rem;
}
.message-ly-header {
line-height: 50px;
}
.message-ly-close {
font-size: 0 .32rem;
color:
z-index: 9 ;
display: inline-block;
width: 25 %;
margin-left: 0 .5rem;
}
.message-ly-tit {
font-size: 0 .5rem;
color:
display: inline-block;
width: 35 %;
text-align: center;
}
width: 1 .3rem;
height: 0 .56rem;
background: linear-gradient( 90deg,rgba( 251,141 ,11,1) ,rgba( 255,193 ,39,1)) ;
border-radius: 0 .28rem;
border: none;
outline: none;
color:
float: right;
margin-right: 0 .3rem;
margin-top: 0 .15rem;
}
.textarea {
position: relative;
/* width: calc( 100 % - 0 .64rem) ; */
height: calc( 100 % - 2 .2rem) ;
padding-bottom: 20px;
border-radius: 8px;
overflow: hidden;
}
.textarea textarea, .textarea textarea:focus {
border: 0 ;
padding: 0 .3rem 0 .3rem 0 .3rem 0 .5rem;
}
textarea {
border: none;
outline: none;
line-height: 2 ;
margin: 0 auto;
width: calc( 100 % - 0 .8rem) ;
height: calc( 100 % - 0 .8rem) ;
font-size: inherit;
resize: none;
padding: 0 .3rem;
color:
}
.textarea::after {
content: attr( currentlength) " / " attr( maxlength) ;
position: absolute;
right: 10px;
bottom: 5px;
font-size: 12px;
color:
}
js
$( '.message-ly') .fadeIn( ) ;
//留言关闭
$( '.message-ly-close') .click( function ( ) {
$( '.message-ly') .fadeOut( ) ;
} ) ;
//留言保存
$( ') .click( function( e) {
e.preventDefault( ) ;
e.stopPropagation( ) ;
var liuyan = $( 'textarea') .val( ) .trim( ) ;
if ( liuyan == '' ) {
tooltipClear( '你还没有留言呢' ) ;
return ;
}
$.ajax( {
url: urls.save_message,
data: {
xh: xh,
content: liuyan
} ,
dataType: 'json' ,
type: 'post' ,
timeout: 10000 ,
success: function( data) {
tooltipClear( '留言已成功,待审核' ) ;
$( '.message-ly') .fadeOut( ) ;
$( 'textarea') .val( '' ) ;
} ,
error: function( xhr, type, errorThrown) {
tooltipClear( '请求服务失败' ) ;
}
} ) ;
} ) ;
//留言
//实时计算textarea长度
$( 'textarea') .on( 'input propertychange' , function ( ) {
var _len = $( this) .val( ) .length;
$( this) .parent( ) .attr( 'currentlength' , _len) ;
} ) ;
$( 'textarea') .focus( function ( ) {
$( this) .parent( ) .css( 'borderColor' , 'rgba(188,66,66,0.8)' ) ;
} ) .blur( function ( ) {
$( this) .parent( ) .css( 'borderColor' , '#ffffff' ) ;
} ) ;