页面溢出时展开图像和导航菜单

时间:2018-11-08 14:11:29

标签: javascript html css asp.net html5

我有一个网站,其中两个页面的内容在小屏幕上溢出,这意味着您必须水平滚动才能查看所有内容。因此,在这两个页面上,菜单和屏幕顶部的徽标图像被切断。菜单和徽标均由母版页加载。我尝试通过使用媒体查询并分配特定的宽度来解决此问题,这确实解决了这两个页面的问题,但是由于该修复影响了母版页,因此导致所有页面在小屏幕上滚动。我认为这是一个非常基本的问题,但令人惊讶的是我找不到任何解决方案。我想知道是否有人对如何解决这个问题有任何想法。

编辑:从我的母版页和样式文件中发布代码。

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #ffffff;
    max-width: none;
    overflow: scroll;
}

table {
    border-spacing: 0px
}

td {
    padding: 2px;
    margin: 0px;
    border-spacing: 0px
}
/*-----------------------------------------------------------------Header Logo------------------------------------------------------------------------------------------------*/

.responsive {
    width: 100%;
    height: auto;
}

/*------------------------------------------------------------------------ Menu -----------------------------------------------------------------------------------------*/
.navbar {
    width: 100%;
    overflow: hidden;
    background-color: #333;
    font-family: Arial, Helvetica, sans-serif;
    margin-top: 0px;
    padding-top: 0px;
}

    .navbar a {
        float: left;
        font-size: 16px;
        color: white;
        text-align: center;
        padding: 14px 16px;
        text-decoration: none;
    }

.dropdown {
    float: left;
}

    .dropdown .dropbtn {
        font-size: 16px;
        border: none;
        outline: none;
        color: white;
        padding: 14px 16px;
        background-color: inherit;
        font-family: inherit;
        margin: 0;
    }

    .navbar a:hover, .dropdown:hover .dropbtn {
        background-color: red;
    }

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}

    .dropdown-content a {
        float: none;
        color: black;
        padding: 12px 16px;
        text-decoration: none;
        display: block;
        text-align: left;
    }

        .dropdown-content a:hover {
            background-color: #ddd;
        }

.dropdown:hover .dropdown-content {
    display: block;
}


/*-----------------------------------------------------------------Formatting------------------------------------------------------------------------------------------------*/

.
.under2 {
    text-decoration: underline;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #3A4A37;
}

.box_app {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #3A4A37;
    border: 1px solid #C4D0C1;
}

.validator {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #F00000;
}

.validator_mini {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #F00000;
}

.validator_mini2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #000080;
}

.subtitles {
    font-weight: bold;
    background-color: #093145;
    border-bottom-style: solid;
    border-bottom-color: #3A4A37;
    border-bottom-width: 1px;
    text-align: left;
    color: white;
}

.textbox_padded {
    border: 1px solid #C4D0C1;
    padding: 4px;
    color: #3A4A37;
    font-family: arial, Helvetica, sans-serif;
}

.title_times_new {
    font-family: "Times New Roman", Times, serif;
    font-size: 32px;
    color: #4D6145;
    font-weight: bold;
    font-style: italic;
    text-align: center;
}

.title_times_new2 {
    font-family: "Times New Roman", Times, serif;
    font-size: 16px;
    color: #4D6145;
    font-weight: bold;
    font-style: italic;
}

.contract_list {
    margin-left: auto;
    margin-right: auto;
}


/*-------------------------------------------------------------------New Contract Form----------------------------------------------------------------------*/
#contract table {
    width: 600px;
}

html, body {
    margin: 0;
    padding: 0;
}

.img-responsive {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

.drop {
    left: 0px;
    margin-right: 90px;
}

.flow {
    width: 1200px
}

/*-------------------------------------------------------------------Media queries----------------------------------------------------------------------*/

@media only screen and (max-width: 1280px) {
    .navbar {
        width: 1670px;
        margin-top: 0px;
    }

    .responsive {
        width: 1670px;
    }

    .contract_list {
        margin-right: 0px;
        margin-left: 1%;
    }
}
<html>
<head runat="server">
    <title></title>

    <link href="~/secure/styles.css" type="text/css" rel="stylesheet" runat="server" />
    <link rel="stylesheet" href="~/secure/font-awesome.min.css" runat="server" />
    <link rel="shortcut icon" type="image/ico" href="images/faviocon/favicon.ico" runat="server" />

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>

</head>
<body>
    <form id="form1" runat="server">
        <img src="images/logo2.png" alt="Logo" runat="server" class="responsive" />
        <div class="navbar" runat="server" style="margin-top: 0px; padding-top: 0px;">
            <div class="dropdown">
                <button class="dropbtn" causesvalidation="false">
                    Clinical Arrangements        
                </button>
                <div class="dropdown-content">
                    <a href="/secure/student_ca_arrangement.aspx">Add New Student</a>
                </div>
            </div>

            <div class="dropdown">
                <button class="dropbtn" causesvalidation="false">
                    Contracts 
                </button>
                <div class="dropdown-content">
                    <a href="/secure/ca_contracts/new_contract.aspx">New Contract</a>
                    <a href="/secure/ca_contracts/contract_list.aspx">Contract List</a>
                </div>
            </div>
            <div class="dropdown">
                <button class="dropbtn" causesvalidation="false">
                    Letters 
                </button>
                <div class="dropdown-content">
                    <a href="/secure/letters/begin_letter_list.aspx">Beginning of Term Letter</a>
                    <a href="/secure/letters/end_letters_list.aspx">End of Term Letter</a>
                </div>
            </div>
            <a id="logout" causesvalidation="false" runat="server" onserverclick="logout_Click">Sign Out</a>
        </div>

        <br />
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>

    </form>
    <script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

您似乎正在手动滚动自己的自适应媒体查询?我建议使用Bootstrap v3-您可以使用程序包管理器来设置整个程序。

在媒体查询中,您将使用像素的固定宽度设置为1670px。在RWD中,永远不会使用固定的宽度单位;它总是以百分比完成的。您可以使用Bootstrap避免这些问题,因为所有繁重的工作已经为您完成。

对于您的特定问题,您应该针对不同的屏幕分辨率使用不同的媒体屏幕:

https://getbootstrap.com/docs/3.3/css/#grid-media-queries

答案 1 :(得分:0)

您可以使用

禁用水平滚动
overflow-x:hidden;

在您的CSS中