原生实现前端表单title两端对齐,value自适应

html 复制代码
<!--
 * @Author: chenzhijie
 * @Date: 2023-06-15 15:54:26
 * @LastEditTime: 2023-06-15 22:48:25
 * @LastEditors: chenzhijie
 * @Description: 
 * @FilePath: \demo\test20230615-2-1.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>test</title>
    <style>
        .label {
            display: flex;
            background-color: antiquewhite;
            width: 300px;
            flex-direction: row;
            position: relative;
            left: 20px;
        }

        .label::before {
            display: flex;
            background: #999;
            content: "";
            position: relative;
            width: 2px;
            left: -14px;
        }

        .one {
            width: 150px;
            display: flex;
            flex-direction: column;
            background-color: antiquewhite;
        }

        .one .item {
            width: 140px;
            display: flex;
            flex-direction: row;
        }

        .one .item .label_1 {
            position: relative;
            width: 100px;
            min-width: 100px;
            text-align: justify;
            text-align-last: justify;
            top: -20px;
        }

        .one .item .label_1::before {
            display: flex;
            background: #999;
            border-radius: 50px;
            content: "";
            height: 20px;
            position: relative;
            top: 50%;
            width: 20px;
            top: 20px;
            left: -25px;
        }

        .one .item .val_1 {
            width: 100px;
            background-color: aquamarine;
            word-wrap: break-word;
        }

        .two {
            flex: 1;
            /* width: 100px; */
            position: relative;
            left: 84px;
            background-color: blueviolet;
        }

        .two .item {
            width: 204px;
            display: flex;
            flex-direction: row;
        }

        .two .item .label_1 {
            position: relative;
            width: 100px;
            min-width: 100px;
            text-align: justify;
            text-align-last: justify;
            top: -20px;
        }

        .two .item .label_1::before {
            display: flex;
            background: #999;
            border-radius: 50px;
            content: "";
            height: 20px;
            position: relative;
            top: 50%;
            width: 20px;
            top: 20px;
            left: -25px;
        }

        .two .item .val_1 {
            width: 100px;
            background-color: aquamarine;
            word-wrap: break-word;
        }
    </style>
</head>


<body>
    <div>
        <div class="label">
            <div class="one">
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">34111111111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">341111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">辖区</div>:
                    <div class="val_1">3411111111111111111111111111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">344444444444444444444444444444444444444444444444444444</div>
                </div>
            </div>
            <div class="two">
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">34111111111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">341111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">辖区</div>:
                    <div class="val_1">3411111111111111111111111111111111111</div>
                </div>
                <div class="item">
                    <div class="label_1">所属辖区</div>:
                    <div class="val_1">344444444444444444444444444444444444444444444444444444</div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

效果图如下:

相关推荐
As977_几秒前
前端学习Day12 CSS盒子的定位(相对定位篇“附练习”)
前端·css·学习
susu10830189112 分钟前
vue3 css的样式如果background没有,如何覆盖有background的样式
前端·css
Ocean☾4 分钟前
前端基础-html-注册界面
前端·算法·html
Dragon Wu6 分钟前
前端 Canvas 绘画 总结
前端
CodeToGym11 分钟前
Webpack性能优化指南:从构建到部署的全方位策略
前端·webpack·性能优化
~甲壳虫12 分钟前
说说webpack中常见的Loader?解决了什么问题?
前端·webpack·node.js
~甲壳虫16 分钟前
说说webpack proxy工作原理?为什么能解决跨域
前端·webpack·node.js
Cwhat17 分钟前
前端性能优化2
前端
熊的猫1 小时前
JS 中的类型 & 类型判断 & 类型转换
前端·javascript·vue.js·chrome·react.js·前端框架·node.js
瑶琴AI前端1 小时前
uniapp组件实现省市区三级联动选择
java·前端·uni-app