开发者社区 问答 正文

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 3914 分享 版权
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
    赞同 展开评论
问答地址: