div文字水平垂直居中 文字自动换行

<%@page contentType="text/html; charset=UTF-8" session="true" %>

<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>

<!DOCTYPE HTML>

<html>

<head>

<meta charset="utf-8">

<%@include file="/WEB-INF/jsp/include/head.jsp" %>

<%@include file="/WEB-INF/jsp/include/global.jsp" %>

<style type="text/css">


   html {overflow-y:auto}

   body{background: transparent;}

   .stastyle {

     height:50px;

     vertical-align: middle;

     line-height: normal;

     width:100px;

     margin:10px 8px 0px 0px;

     float:left;

     border:solid 1px #1e88e5;

     background:#123660;

     color:#ffffff;

     overflow: hidden;

     text-align: center;

   }

   .stastyle:hover {

    background:#315d8f;

    cursor:pointer;

   }

    .sleft {

     margin-top: 12px;

     display: inline-block;

     position: relative;

     overflow: hidden;

     padding: 0;

     vertical-align: top;

   }

   .stext {

    display: inline-block;

    vertical-align: top;

    width: auto;

    line-height: 24px;

    font-size: 12px;

    padding: 0;

    margin: 0 4px;

   }

</style>

</head>

<body>

<div style="height:100%; width:100%; text-align:center; margin:0px auto 0 auto;">

     <div id="station" style="height: 325px;width:350px;overflow-y: auto;"></div>

</div>

<script type="text/javascript">

$(function(){

var goalIndexId='${indexId}';

var goalUnitId='${unitId}'; 

seledarea(goalIndexId,goalUnitId);

}); 


//展现选中区域各台数据

function seledarea(indexId,unitId){

$.ajax({

type:"post",

url : "${ctx}/tousu/getseledarea",

data:{

"unitId":unitId

},

success:function(data){

$('#station').empty();

if(data.showtabel!=""){

for(var i=0;i<data.showtabel.length;i++){

createstadiv(data.showtabel[i]);

}

}

}

});

}

function createstadiv(showtabel){

var name = showtabel.name;

var id = showtabel.id;

var html = "";

html = "<div class='stastyle' onclick='javascript:onStaclick("+id+",\""+name+"\");'><span class='sleft'><span class='stext'>"+name+"</span></span></div>";

// html = "<a  href='javascript:onStaclick("+id+",\""+name+"\");' class='easyui-linkbutton' style='height:50px;width:100px;margin:10px 10px 0px 0px;float:left;'>"+name+"</a>";

$('#station').append(html);

//$.parser.parse("#station");

}


function onStaclick(unitid,name){

parent.setParams();

parent.parent.setGoalUnitId(unitid,true);

}

</script>

</body>

</html>


你可能感兴趣的:(div文字水平垂直居中 文字自动换行)