zoukankan      html  css  js  c++  java
  • 任意大小图片+文字,垂直水平居中显示

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>图片文字,垂直水平居中显示</title>
    <style type="text/css">
    .picbg{
    background-size: contain;display: block;border:1px solid #e3e3e3; 25%;
    margin: 0 5%;height:250px;
    position: relative;overflow: hidden;float: left;
    }
    .picbg img{
    display:block;
    background: red;
    margin: 0 auto;
    max- 100%;超出宽度的图片限制最大显示宽度
    max-height:250px;//超出高度的图片限制最大显示高度
    position: absolute;
    top: 50%;
    left: 50%;
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    }
    .picbg .title{
    100%;height: 100%;position: absolute;top:0;
    text-align: center;
    }
    .picbg .title>div{
    100%;
    position: absolute;top:50%;margin-top: -39px;
    }
    .picbg .title p{
    font-size: 26px;color: #6c6c6d;height: 26px;
    text-align: center;line-height: 26px;
    }
    </style>
    </head>
    <body>

    <div class="picbg">
    <div class="courseLive"></div>
    <img src="img/3.jpg" alt="1" class="center">
    <div class="title">
    <div><p>城市风格</p></div>
    </div>
    </div>
    <div class="picbg">
    <div class="courseLive"></div>
    <img src="img/a.png" alt="2" class="center" >
    <div class="title">
    <div><p>城市风格</p></div>
    </div>
    </div>
    </body>
    </html>

  • 相关阅读:
    Python | PyQt5编写计时器与倒计时应用程序
    AI文件与PS文件相互导入,并分层可编辑
    maple解方程组
    有限元数值分析
    常用Latex编辑数学公式
    notion
    总结一下ANSYS中不同单元之间选择与连接问题
    参考文献的引用方法
    Abaqus CAE笔记本
    几种大文件传输的平台
  • 原文地址:https://www.cnblogs.com/luckyuns/p/6273467.html
Copyright © 2011-2022 走看看