【问题标题】:Content not showing on mobile device内容未在移动设备上显示
【发布时间】:2025-12-07 11:45:01
【问题描述】:

我在一个网站上工作,当在移动设备上使用时,除了下面的页面之外,它都可以正常工作。 当该菜单部分处于活动状态时,手风琴应该可以显示菜单项,但在移动设备上,当手风琴处于活动状态时内容不会显示?

http://valleyinn.ie/menus/menus.html

html

<H1> A La Carte Menu </H1>
    <div class="wrapper"> 
    <ul class="accordion">
        <li class="nav-dropdown">
            <input type="radio" name="accordion" id="menu 1" />
            <label for="menu 1">
                Starters
            </label>
            <div>
                <h2>Starters</h2>
                <p>Prawn cocktail : Clogherhead prawns coated in Marie Rose sauce served with salad</p>
                <p>Garlic Bread: Garlic bread coated with mozarella cheese</p>
                <p>Bruchetta: Garlic toastie with tomato, basil and melted mozzarella</p>
                <p>Deep Fried Brie: Breaded parcels of Brie deep fried and served with redcurrant jelly</p>
                <p> Garlic Mushrooms: Deep fried breaded mushrooms with garlic mayonnaise</p>
                <P>Fan of Melon: Fan of honeydew melon served with Raspberry Coulis</P>
                <p>Caesar Salad: Crispy cos tossed with bacon, croutons & creamy caesar dressing with parmesan shavings</>
                <p>Soup of the Day
                <p>Chicken Wings: Marinated chicken wings served with sweet chilli dip & side salad</p>
                <p>Egg Mayonnaise</p>
                <P>Tiger Prawns: Served with honey mustard dressing & garlic bread</P>
            </div>
        </li>

和css

div#title {
    text-align:center;
}
body div.wrapper {
    clear:both;
    border: 1px solid #dedede;
    margin: 25px auto;
    overflow: hidden;
    width: 80%;
 }   
ul.accordion {
    list-style-type: none;
    margin: 0;
    padding: 0;
}
ul.accordion li input {
    display: none;
    padding: 0;
    margin: 0;
    visibility: hidden;
}
ul.accordion label {
    background-color: #000000;
    border-bottom: 1px solid #dedede;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.055);
    color:  #F9C921;
    display: block;
    font-weight: bold;
    line-height: 42px;
    padding: 0 8px;
}
ul.accordion label:hover {
    background-color: #F9C921;
    color:#000000;
    cursor: pointer;    
}
ul.accordion li input ~ div {
    background-color: rgba( 0, 0, 0, .05 );
    max-height: 0;
    opacity: 0;
overflow: hidden;
    visibility: hidden;
    -webkit-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -ms-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}
ul.accordion li input ~ div p {
    font-size: .9em;
    margin: 16px 24px;  
}
h1 {
    clear:both;
}
ul.accordion li input:checked ~ div {
    max-height: 100%;
    opacity: 1;
    visibility: visible;
}
ul.accordion li input:checked ~ div > ul {
    display: block; 
    -webkit-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -ms-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}

除了制作一个我以前没有做过的移动设备特定页面之外,我想不出从哪里开始的任何可能的修复或解决方法

通过更改代码来避免问题解决。

【问题讨论】:

  • 它不适用于我尝试过的任何移动浏览器,例如 chrome 和 safari,我正在尝试您现在建议的所有修复,感谢您的建议,我会告诉您它是否有效
  • 只是再次查看您的网站 - 我会在这些扩展选项卡中使用表格,这样您就可以拥有菜肴的标题、描述,也许还有价格?
  • 决定只使用一点 javascript 而没有 ios 的下拉菜单让事情变得更容易我认为

标签: html css


【解决方案1】:

总之,不同的浏览器解析代码的方式不同。有些在自动“修复” HTML 错误方面做得更好。检查您正在使用移动设备的浏览器是否已更新。然后检查它是否支持该方法。

在您的代码中: 您缺少一个结束&lt;/p&gt;,因为它仅显示为&lt;/&gt;,两个是大写&lt;/P&gt;,因此将它们更改为小写&lt;/p&gt;soup of the day 缺少一个结束&lt;/p&gt;。还将 ID 名称从 menu 1 更改为 menu_1

【讨论】:

  • 更改了代码,几乎没有变化,浏览器都是最新的,但我如何检查它是否支持?
  • 尝试:将 &lt;H1&gt; 更改为 &lt;h1&gt; 和关闭 &lt;/H1&gt; 相同。另外,你打开&lt;div&gt;'s 但没有在任何地方关闭它们?
  • 可能在代码末尾关闭如果您查看该站点,则有很多重复的代码,因此 div 接近结束手风琴组。 H 不应该关心它在

    中没有显示的代码

  • &lt;ul&gt; 标签是否正在关闭?
  • 是的,每个部分都以
    结尾
最近更新 更多