CSS Form表单布局

效果图

复制代码
<Tab IsCard="true">
    <TabItem Text="表单信息-DIV版本">

        <div class="row">
            <div class="col">
                <label for="field1">工程名称:</label>
                <input class="form-control" type="text" id="field1" name="field1" value="默认值1">
            </div>
            <div class="col">
                <label for="field2">年龄:</label>
                <input class="form-control" type="text" id="field2" name="field2" value="默认值2">
            </div>
        </div>
        <div class="row">
            <div class="col">
                <label for="field3">测试长标题:</label>
                <input class="form-control" type="text" id="field3" name="field3" value="默认值3">
            </div>
            <div class="col">
                <label for="field4">对齐:</label>
                <input class="form-control" type="text" id="field4" name="field4" value="默认值4">
            </div>
        </div>

    </TabItem>

</Tab>


<style type="text/css">
    .row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px; /* 添加行之间的间隔 */
    }

    .col {
        display: flex;
        flex-direction: row;
        align-items: center;
        flex: 1;
        margin-right: 10px;
    }

    label {
        width: 80px; /* 例如,设置固定宽度为80px */
        flex-shrink: 0; /* 防止标签缩小 */
        margin-right: 5px; /* 可以调整label和input之间的间距 */
        text-align:right;
    }

    input[type="text"] {
        flex: 1;
        width: 100%;
        /* 这里可以添加其他输入框样式,比如边框、填充等 */
    }

</style>
相关推荐
Charlie_lll3 小时前
学习Three.js–雪花
前端·three.js
onebyte8bits4 小时前
前端国际化(i18n)体系设计与工程化落地
前端·国际化·i18n·工程化
C澒4 小时前
前端分层架构实战:DDD 与 Clean Architecture 在大型业务系统中的落地路径与项目实践
前端·架构·系统架构·前端框架
BestSongC4 小时前
行人摔倒检测系统 - 前端文档(1)
前端·人工智能·目标检测
0思必得04 小时前
[Web自动化] Selenium处理滚动条
前端·爬虫·python·selenium·自动化
Misnice4 小时前
Webpack、Vite、Rsbuild区别
前端·webpack·node.js
青茶3604 小时前
php怎么实现订单接口状态轮询(二)
前端·php·接口
大橙子额5 小时前
【解决报错】Cannot assign to read only property ‘exports‘ of object ‘#<Object>‘
前端·javascript·vue.js
RFCEO5 小时前
前端编程 课程十六、:CSS 盒子模型
css·前端基础课程·css盒子模型·css盒子模型的组成·精准控制元素的大小和位置·css布局的基石·内边距(padding)
爱喝白开水a7 小时前
前端AI自动化测试:brower-use调研让大模型帮你做网页交互与测试
前端·人工智能·大模型·prompt·交互·agent·rag