• 【CSS】让textarea在div里水平垂直都居中的三种办法


    源码下载:https://files.cnblogs.com/files/heyang78/hvcenter_211214.rar

    实现一:(在Editplus和chrome都通过)

    先上图:

     

    代码:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>textarea在div内水平垂直都居中的实现一</title>
    <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
    <style type="text/css">
        .outerDiv{
            width:400px;
            height:400px;
            margin:0 auto;
            border:1px solid red;
            position:relative;
        }
        .outerDiv textarea{
            width:200px;
            height:200px;
            position:absolute;
            left:100px;
            top:100px;
        }
    </style>
    </head>
    <body>
        <div class="outerDiv">
            <textarea cols=20 rows=20>1234</textarea>
        </div>
    </body>
    <script type="text/javascript">
        
    </script>
    </html>

    实现2:(在Editplus和chrome都通过)

     代码:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>textarea在div内水平垂直都居中的实现二</title>
    <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
    <style type="text/css">
        .outerDiv{
            width:400px;
            height:400px;
            margin:0 auto;
            border:1px solid red;
            position:relative;
        }
        .outerDiv textarea{
            width:200px;
            height:200px;
            position:absolute;
            left:50%;
            top:50%;
            transform:translate(-50%,-50%);
        }
    </style>
    </head>
    <body>
        <div class="outerDiv">
            <textarea cols=20 rows=20>1234</textarea>
        </div>
    </body>
    <script type="text/javascript">
        
    </script>
    </html>

    实现代码3:(仅在Chrome好用)

     

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>textarea在div内水平垂直都居中的实现三</title>
    <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
    <style type="text/css">
        .outerDiv{
            width:400px;
            height:400px;
            margin:0 auto;
            border:1px solid red;
            display:flex;
            justify-content:center;
            align-items:center;
        }
        .outerDiv textarea{
            width:200px;
            height:200px;
        }
    </style>
    </head>
    <body>
        <div class="outerDiv">
            <textarea cols=20 rows=20>1234</textarea>
        </div>
    </body>
    <script type="text/javascript">
        
    </script>
    </html>

    参考资料:

    https://blog.csdn.net/weixin_36095188/article/details/113047506

    END

  • 相关阅读:
    prometheus TSDB和外部存储系统
    Prometheus时序数据
    Prometheus简介
    Docker网络
    Ingress
    CRI和多容器运行时
    K8s容器存储接口(CSI)介绍
    EasyNVR视频广场点击视频后切换码流才能播放是什么原因?
    EasyNVR更新H265转H264模块内存增长且显示占用高如何解决?
    EasyNVR拉公网RTSP流失败问题调试和解决
  • 原文地址:https://www.cnblogs.com/heyang78/p/15689557.html
Copyright © 2020-2023  润新知