开发者社区> 问答> 正文

li里面的文字在 li 框里居中

 <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>宽度和高度</title>
<style type="text/css">
li{
    border:1px dotted #ccc;
    width:200px;
    height:30px;
    text-align :center;
    padding-bottom:auto;
}
</style>
</head>
<body>
<ul>
    <li>别让不会说话害了你</li>
    <li>二十七八岁就应该有的见识</li>
    <li>别让不好意思害了你</li>
</ul>
</body>
</html>

怎么讲 li里面的文字在 li 框里居中 上下左右都居中

展开
收起
小旋风柴进 2016-03-13 08:09:38 3749 0
1 条回答
写回答
取消 提交回答
  •  li{
        border:1px dotted #ccc;
        width:200px;
        height:30px;
        text-align :center;
        padding-bottom:auto;
        line-height:30px;
    }

    样式加一个

    line-height:30px;,这个高度等于height就行了
    
    2019-07-17 19:01:33
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载