gpt4 book ai didi

css - 填充 CSS 菜单时遇到问题

转载 作者:行者123 更新时间:2023-11-28 04:02:09 33 4
gpt4 key购买 nike

我被要求“修复”一个客户的旧网站,该网站是在 2011 年编写的,一个设计团队显然在努力理解当时的新 HTML5+CSS。这段代码有很多错误,其中大部分我已经能够修复,比如使用

<p>&nbsp;</p>

用于换行。我不是在开玩笑。

无论如何,我被要求做的一件事是扩展网站的文本容器和菜单,并拉伸(stretch)菜单的实际文本以适应新的宽度,这很顺利。但是,我在填充菜单文本时遇到了一些问题。我在论坛中搜索了一些建议,并尝试了建议的样式代码,但它似乎将菜单文本移到了需要它的 menu.jpg 区域之外。

CSS(这是客户的,所以对他们大吼大叫)

#header_menu_container
/* This is verbatim from the code I am working with. I seriously have NO IDEA why this selector even exists. */
{


}

#header_menu
{
margin: 0;
display: inline-block;
list-style: none;
font-size: 15px;
}

/* header menu colour */
#header_menu li a {
color: #516a82;
}
/* menu hover colour */
#header_menu li a:hover{
color: #b55239;
text-decoration: none;
}

.no_submenu, .has_submenu
{
display: block;
float: left;
position: relative;
}

.no_submenu a, .has_submenu span{
display: block;
font-size: 15px;
font-family: "Times New Roman", Times, serif;
color: #516a82;
text-decoration: none;
}

.no_submenu a:hover, .has_submenu span:hover{
color: #b55239;
}

.has_submenu span{
cursor: pointer;
_cursor: hand;
}

.is_submenu{
position: absolute;
left: -10px;
top: 32px;
background: #dfd7c5;
margin: 0;
padding: 0;
list-style: none;
z-index: 9999;
}

.is_submenu li a{
display: block;
text-align: left;
padding-left: 10px;
width: 122px;
padding-right: 10px;
font-size: 15px;
font-family: "Times New Roman", Times, serif;
color: #516a82;
text-decoration: none;
pading-top: 10px;
padding-bottom: 10px;
line-height: 18px;
}

.is_submenu li a:hover{
color: #b55239;
}

HTML(基于客户的,有一点我的修改)

<ul id="header_menu">
<li class="no_submenu" style="width: 63px;">
<b><a href="./index.html">Home</a></b>
</li>
<li class="has_submenu" id="who-we-are">
<b><span style="width: 103px;">Who We Are</span></b>
<ul class="is_submenu" style="display: none;">
<li>
<b><a href="./whoweare_janyce-lastman.html">Janyce Lastman</a></b>
</li>
<li>
<b><a href="./whoweare_ziny-kirshenbaum.html">Ziny Kirshenbaum</a></b>
</li>
<li>
<b><a href="./whoweare_tutors.html">Tutors</a></b>
</li>
</ul>
</li>

<li class="has_submenu" id="services"><span style="width: 73px;"><b>Services</b></span>
<ul class="is_submenu" style="display: none;">
<li>
<b><a href="./services_consultant-to-schools.html">Consultant To Schools</a></b>
</li>
<li>
<b><a href="./services_education-consulting-and-case-management.html">Education Consulting And Case Management</a></b>
</li>
<li>
<b><a href="./services_educational-assessments.html">Educational Assessments</a></b>
</li>
<li>
<b><a href="./services_school-placement-consultation.html">School Placement Consultation</a></b>
</li>
<li>
<b><a href="./services_seminars-and-workshops.html">Seminars And Workshops</a></b>
</li>
<li>
<b><a href="./services_test-tips-support.html">Test Tips Support</a></b>
</li>
<li>
<b><a href="./services_tutoring.html">Tutoring</a></b>
</li>
</ul>
</li>

<li class="has_submenu" id="media-and-press">
<span style="width: 113px;"><b>Media &amp; Press</b></span>
<ul class="is_submenu" style="display: none;">
<li>
<b><a href="./media-and-press_in-the-press.html">In the Press</a></b>
</li>
<li>
<b><a href="./media-and-press_book-reviews.html">Book Reviews</a></b>
</li>
<li>
<b><a href="./media-and-press_selected-articles.html">Selected Articles</a></b>
</li>
<li>
<b><a href="./media-and-press_interesting-links.html">Interesting Links</a></b>
</li>
</ul>
</li>
<li class="no_submenu" style="width: 53px;">
<a href="./faq.html"><b>FAQ</b></a>
</li>

<li class="has_submenu" id="testimonials"><span style="width: 103px;"><b>Testimonials</b></span>
<ul class="is_submenu" style="display: none;">
<li>
<b><a href="./testimonials_ttg-tutors.html">Testimonials for TTG Tutors</a></b>
</li>
<li>
<b><a href="./testimonials_janyce-lastman.html">Testimonials for Janyce Lastman</a></b>
</li>
</ul>
</li>

<li class="has_submenu" id="contact-us">
<span style="width: 70px;"><b>Contact</b></span>
<ul class="is_submenu" style="display: none;">
<li>
<b><a href="./contactus_contact-info.html">Contact Info</a></b>
</li>
<li>
<b><a href="./contactus_employment-opportunities.html">Employment Opportunities</a></b>
</li>
</ul>
</li>
</ul>
</div>

类选择器中有一个显示调用,这可能是问题的一部分,但我的直觉告诉我,这需要更专业的人来剖析它的所有问题。

弄清楚自己的代码有什么问题是一回事,尝试分析别人的代码有什么问题又是另一回事。任何建议将不胜感激:)

最佳答案

所以再次回顾代码,我想我已经找到问题了。

原始作者没有在 CSS 中放置填充,而是在 每个菜单 的 HTML 样式标记中放置了数字宽度,例如

<span style="width: 73px;"><b>Services</b></span>

白痴。

我将尝试将类似的内容正确地写入样式表。

关于css - 填充 CSS 菜单时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145732/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com