html中元素盒子垂直居中的实现方法

复制代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>元素盒子垂直居中的实现方法</title>
<style type="text/css">
#parent {
    width:500px;
    height:500px;
    background-color:#188eee;
display: table;}
#child {
    width:100px;
    height:auto;
    max-height:200px;
    overflow-y:scroll;
    
    display: table-cell;
    vertical-align: middle;
}
#child text{
    display:block;
    width:80%;
    margin-left:10%;
    height:40px;
    line-height:40px;
    background-color:#fff;
    text-align:center;
    border-bottom:1px #f1f1f1 solid;
}
#child text:last-child{
    border-bottom:0px;
}
</style>
</head>

<body>
<div id="parent">
    <div id="child">
        <text>111</text>
        <text>222</text>
        <text>333</text>
        <text>444</text>
        <text>555</text>
    </div>
</div>

</body>
</html>
复制代码

 

posted @   生如逆旅,一苇以航  阅读(1570)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示