【问题标题】:Why does the textbox and button looks out of layout on different screens?为什么文本框和按钮在不同的屏幕上看起来不布局?
【发布时间】:2018-05-05 13:14:07
【问题描述】:

为什么我的页面,尤其是文本框和按钮部分在不同于笔记本电脑或 PC 的屏幕上显得格格不入?

在平板电脑或 40 英寸屏幕上出现故障。如何在所有类型中维护它?

我使用了引导程序等和一些自定义 css,但文本框和按钮部分仍然不碍事。

<div id="appointments" class="appointment-main-block appointment-two-main-block">
    <div class="container">
        <div class="row topheaderMargin">
            <div class="section text-center">
                <h3 class="section-heading text-center">Select Services</h3>
            </div>

            <div class="col-md-8 col-sm-12" style="width: 100% !important">
                <div class="appointment-block">

                    <h5 class="form-heading-title"><span class="form-heading-no">1.</span>Services</h5>
                    <div class="row">

                        @using (Html.BeginForm())
                        {
                            <div class="col-sm-6">
                                @*<input type="text" class="form-control date-pick searchBox" id="appointment-date" placeholder="Appointment Date">*@
                                @Html.EditorFor(Model => Model.Booking_ID, new { htmlAttributes = new { @class = "form-control searchBox", placeholder = "Booking ID" } })
                                @Html.ValidationMessageFor(Model => Model.Booking_ID, "", new { @class = "ErrorMessages searchBox" })
                            </div>
                            <button type="button" onclick="selectService()" class="btn btn-primary pull-right searchButton">Save</button>
                        }

                    </div>
                    <div class="table-responsive">
                        <table id="tblServices" class="table table-condensed table-responsive tableBody">

                            <thead>
                                <tr>

                                    <th>S.No</th>
                                    <th>Service Name</th>
                                    <th>Service Price</th>

                                </tr>
                            </thead>
                            <tbody id="tbodytblServices"></tbody>

                        </table>
                    </div>

                </div>

            </div>
        </div>
    </div>
</div>

更新:

自定义 CSS:

.ErrorMessages {
    font-size: small;
    color: tomato;
}

.fa-Icons-Padding {
    padding-top: 33px;
}

.MessageStrip {
    background-color: #0891ff !important;
    color: white !important;
    text-align: center !important;
    font-family: arial !important;
    font-weight: bold !important;
}

.Container-IndexPage {
    padding-right: 0%;
    padding-left: 0%;
}

.topBar {
    background-color: #F4F4F4 !important;
}

.searchBox {
    margin-left: 73%;
    width: 60% !important;
    border-color: lightgrey !important;
}

.searchButton {
    margin-right: 29%;
}

.searchButton {
    margin-right: 28.7%
}

.AddServicesSearchButton 
{
    margin-right: 7.7%;
    margin-top: -8%;
}

.datatable-headerrow {
    background-color: #F4F4F4 !important;
}

.pagination-buttons {
    background: linear-gradient(to bottom, #0891FF 0%, #0891FF 100%) !important;
    color: white !important;
}

.searchbox-border {
    border-color: lightgrey !important;
}

.tableBody {
    font-size: 16px !important;
    font-family: calibri !important;

}

.btnCheckIn {
    margin-right: 61%;
    margin-top: 1%;
}

.btnEdit {
    color: #fff !important;
    background-color: #0891FF !important;
    /*margin-right: -670%;
margin-top: -25%;*/
}

.btnBill 
{

    margin-right: 4%;
    margin-top: -18%;
    background-color: #03C04A;
}

.btnCancel {
    color: #fff !important;
    background-color: tomato !important;
    margin-right: 27%;
    margin-top: -18%;
}

.searchButtonConfirmationCancellation {
    margin-right: 28.7%;
}

.addCustomerBtn {
    margin-left: 376%;
    margin-top: 5%;
    margin-bottom: 5%;
}

.printDiv {
    text-align: center;
    margin-bottom: 1.5%;
}

.pad-container {
    padding-top: 0% !important;
}

.table-header {
    font-size: 81%;
    font-family: arial;
}

.specialh3 
{
    text-align: center;
    text-transform: capitalize;
}

.selectColumn 
{
    margin: 11px -13px 14px !important;
}

.InvoiceTable 
{
    width: 50%;
    margin-left: 25%;
    margin-top: 1%;
    border: 1px gray dashed;
}
.Copies 
{
    margin-left: 46%;
    margin-top: 1% !important;
    font-size: 11px !important;

}

.topheaderMargin 
{
    margin-top: -5%;
}

【问题讨论】:

  • “超出布局”是什么意思。请添加更多细节,如不同屏幕上的网页截图。
  • @BharatSahlot 错位,chota bara
  • 你能添加一个显示错误的 plunkr 吗?当我获取您的代码并稍微修改它以不使用 asp.net 标签时,我得到了一个非常正确的布局? embed.plnkr.co/CDDvQLhIqtDy59mZ1Nni你能提供你的自定义css吗?
  • 您是否进行了研究,因为这是很多人提出的问题。这也可能是:- stackoverflow.com/questions/8733795/…stackoverflow.com/questions/17604311/…
  • @BharatSahlot 是的太多了,但没有什么是正确的

标签: html css twitter-bootstrap layout frontend


【解决方案1】:

在我看来,您只需要用一个 div 围绕您的按钮,该 div 可以正确放置在网格布局中。

<div class="col-sm-2 col-sm-pull-4">
   <button type="button" onclick="selectService()" class="btn btn-primary pull-right searchButton">Save</button>
</div>

该按钮不在网格布局使用的容器中,因此它没有相应地放置,也没有使用引导程序中定义的任何顶级布局。

在您的布局中我并没有真正理解不同的东西。我会建议你不同的东西。我将它们合并到这个 plunker 中。请看一下。如果您有任何问题,请随时发表评论。
https://embed.plnkr.co/Q9qRsq7PdbsOjyMD2dXB/

也许您需要查看引导文档。它应该根据网格布局澄清许多问题:
https://getbootstrap.com/docs/4.0/layout/grid/

请注意,随着 Bootstrap 4 的发布,一些用于在网格布局中定位 cols 的类已更改或扩展。如果您使用的是像 bootstrap 3 这样的旧版本,请查看相应的文档。
https://getbootstrap.com/docs/3.3/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-03
    • 2020-05-27
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 2014-11-04
    • 2014-10-30
    • 1970-01-01
    相关资源
    最近更新 更多