【问题标题】:Build a table look a like with HTML and CSS使用 HTML 和 CSS 构建一个看起来像的表格
【发布时间】:2022-11-21 02:59:25
【问题描述】:

我尝试构建一个 div 容器,其中包含以下项目,相同的位置和颜色。 我可以用 html 和 <table> 构建它,但我只想使用 html 和 css。我尝试了 display: flex、display: inline 和所有这些东西。但正确的“不在行”部分让我哭了。 有人可以帮忙吗?

.d1{
    display:flex;
    flex-direction:column;
    height: auto;
}
.d1 p{
    margin-top: 3px;
    margin-left: 10px;
    width:110px;
}
.d1a {
    display: flex;
    flex-direction: column;
    height: auto;
}
.d1aa{
    display: flex;
    flex-direction:row;
}
.divInline{
    display:flex;
    flex-direction:row;
}
.white{
    background-color: #ffffff;
}
.grey{
    background-color: grey;
}
.box-shadow-topleft {
    box-shadow: inset 2px 2px 5px 0px rgba(0,0,0,0.75);
}
<div class="d1">

    <div class="divInline">
        <div class="box-shadow-topleft">
            <p>Rechnungs-Nr:</p>
        </div>
        <div>
            <input class="white" id="rgNrVorauswahl" disabled />
        </div>
        <div>
            <input class="white" id="rgNrKkunde" disabled />
        </div>
    </div>
    <div class="d1a">

        <div class="d1aa">
            <div class="divInline">
                <div class="box-shadow-topleft">
                    <p>Rechnungs-PK:</p>
                </div>
                <div>
                    <input class="grey" id="rechnungsPK" disabled />
                </div>
            </div>
        </div>
        <div class="d1extra">
            <p>Restbetrag:</p>
            <input class="grey" id="rgrest" disabled value="336" />

        </div>
    </div>


</div>

【问题讨论】:

  • 感谢 Emre 的编辑。
  • 使用表格并为其设置样式。如果不这样做,您将失去大部分可访问性优势,并且必须重新开发它。例如,代码中的每个输入都必须有一个与之链接的相应标签。
  • 不客气,斯蒂芬。我想你的需求在这里:How to Create Responsive Tables using CSS without <table> Tag

标签: html css flexbox display


【解决方案1】:

你也可以发布 HTML 代码吗

【讨论】:

    猜你喜欢
    • 2014-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    相关资源
    最近更新 更多