gpt4 book ai didi

html - 菜单上的底部边框在 hoover 上延伸得太远

转载 作者:行者123 更新时间:2023-11-28 05:45:49 25 4
gpt4 key购买 nike

我在我的页面上创建了一个响应式纯 css 菜单,除了悬停外,它工作得很好。悬停时,我需要它在菜单文本下绘制一条洋红色线。这已经有效,但是该行延伸到单词末尾之外太远了。它应该只强调这个词。我以前有过这个工作,所以我知道它可以完成,但那是通过不同的菜单实现的,我是通过随机敲击按键实现的,所以我不知道如何重复它。

这可能是重复的。我注意到另外两个相关的帖子,但我无法让他们的解决方案起作用,所以要么这是一个不同的问题,要么我不知道如何正确地将更改应用到我的代码。

这是目前的样子: Border extends too far

HTML

@{
ViewBag.Title = "_Layout";
}
<link href="~/Content/Site.css" rel="stylesheet" />

<div class="wrapper">
<header class="header">
<a href="/" class="logo">
<img src="~/Images/companylogo.png" />
</a>
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<ul class="menu">
<li><a href="#about">About</a></li>
<li><a href="#residential">Residential &amp; Business</a></li>
<li><a href="#accountDetails">My Account Details</a></li>
<li><a href="#faq">FAQ</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</header>
<!--End of code for responsive menu-->
<!--HEADER END-->
<div class="page-content">
<div class="cloud1">
<img src="~/Images/cloud1.png" />
</div>
<div class="cloud2">
<img src="~/Images/cloud2.png" />
</div>
<div class="cloud3">
<img src="~/Images/cloud3.png" />
</div>
<div class="cloud4">
<img src="~/Images/cloud4.png" />
</div>
<!--CONTENT START-->
<div class="box">
@RenderBody()
</div>
<!--CONTENT END-->
</div>
<!--FOOTER START-->
<div class="bottom">
<div class="padt120">
<img src="~/Images/about-buildings.png" alt="Buildings" class="buildings" />
<div class="grass"></div>
</div>

<footer class="padtb30">
<span class="copyright">
<small class="lightgrey-text">
&copy; Copyright 2016. All Rights Reserved. SomeCompany Inc. <a href="http://somecompany.com/privacypolicy">Privacy Policy</a>
</small>
</span>
</footer>
</div>
</div>

CSS

@font-face {
font-family: 'HelveticaNeue-Thin';
src: url('../Resources/HelveticaNeue-Thin.woff') format('woff');
}

@font-face {
font-family: 'HelveticaNeue';
src: url('../Resources/HelveticaNeue.woff') format('woff');
}

@font-face {
font-family: 'fontawesome-webfont';
src: url('../Resources/fontawesome-webfont.ttf') format('truetype');
}

@keyframes cloud1 {
0% {
left: -488px;
top: 100px;
}

100% {
left: 100%;
top: 100px;
}
}

@keyframes cloud2 {
0% {
left: -215px;
top: 200px;
}

100% {
left: 100%;
top: 200px;
}
}

@keyframes cloud3 {
0% {
left: -421px;
top: 300px;
}

100% {
left: 100%;
top: 300px;
}
}

@keyframes cloud4 {
0% {
left: -359px;
top: 400px;
}

100% {
left: 100%;
top: 400px;
}
}

body {
padding-top: 50px;
padding-bottom: 20px;
background-image: linear-gradient(#B2D2EA, #ffffff);
overflow-x: hidden;
}

.header {
background-color: #fff;
position: absolute;
display: table;
top: 0;
left: 0;
width: 100%;
height: 80px;
z-index: 3;
font-family: HelveticaNeue-Thin;
font-size: medium;
}

.header ul {
align-self: center;
height: auto;
margin: 0;
padding: 8px 5%;
list-style: none;
overflow: hidden;
background-color: #fff;
}

.heading li {
display: inline;
padding: 5px;
}

.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
border-bottom: 3px solid transparent;
transition: 0.5s ease;
white-space: nowrap;
color: #171581;
}

.header li a:hover {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}

a::after {
display: block;
content: attr(title);
font-family: HelveticaNeue-Thin;
height: 1px;
color: transparent;
overflow: hidden;
visibility: hidden;
margin-bottom: -1px;
}

#about {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}

#residential {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}

#myaccountdetails {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}

#faq {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}

#contactus {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}

.header .logo {
display: table-cell;
height: 100%;
padding-left: 5%;
vertical-align: middle;
}

.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
/*End of code added for menu*/
/*Style menu icon*/
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}

.header .menu-icon .navicon {
background: #80BD01;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}

.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #80BD01;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}

.header .menu-icon .navicon:before {
top: 5px;
}

.header .menu-icon .navicon:after {
top: -5px;
}
/*End of style for men icon*/
/*Icon and menu animations when the checkbox is clicked*/
.header .menu-btn {
display: none;
}

.header .menu-btn:checked ~ .menu {
max-height: 240px;
}

.header .menu-btn:checked ~ .menu-icon .navicon {
background: transparent;
}

.header .menu-btn:checked ~ .menu-icon .navicon:before {
transform: rotate(-45deg);
}

.header .menu-btn:checked ~ .menu-icon .navicon:after {
transform: rotate(45deg);
}

.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
top: 0;
}
/*End of menu and icon animations*/
/*Show the horizontal menu items for larger browser widths by default*/
@media (min-width: 48em) {
.header li {
float: left;
}

.header li a {
margin: 0;
padding: 20px 30px;
}

.header .menu {
clear: none;
float: right;
max-height: none;
}

.header .menu-icon {
display: none;
}
}
/*End of menu items for large browser widths*/
.page-content {
font-family: HelveticaNeue;
margin-left: 10%;
margin-right: 10%;
padding-top: 50px;
padding-bottom: 100px;
max-width: 100%;
height: auto;
text-align: center;
}

.cloud1 {
animation-name: cloud1;
animation-duration: 25s;
animation-iteration-count: infinite;
position: absolute;
top: 100px;
left: -488px;
z-index: -1;
}

.cloud2 {
animation-name: cloud2;
animation-duration: 25s;
animation-delay: 10s;
animation-iteration-count: infinite;
position: absolute;
top: 200px;
left: -215px;
z-index: -1;
}

.cloud3 {
animation-name: cloud3;
animation-duration: 20s;
animation-delay: 7s;
animation-iteration-count: infinite;
position: absolute;
top: 300px;
left: -421px;
z-index: -1;
}

.cloud4 {
animation-name: cloud4;
animation-duration: 30s;
animation-delay: 10s;
animation-iteration-count: infinite;
position: absolute;
top: 400px;
left: -359px;
z-index: -1;
}

.box {
background-color: #F28B20;
border-radius: 5px;
height: auto;
margin-bottom: 150px;
width: 80%;
display: inline-block;
box-shadow: 10px 10px 5px #888888;
background-image: url("../Images/logo_faded_background-2.png");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}

.bottom {
position: relative;
height: auto;
width: 100%;
}

.grass {
height: 20px;
width: 100%;
background-color: #80BD01;
}

.padtb30 {
width: 100%;
position: absolute;
bottom: 0;
height: 80px;
line-height: 80px;
background-color: #ffffff;
text-align: center;
}

.buildings {
display: block;
margin: 0 auto;
}

.padt120 {
position: absolute;
width: 100%;
height: 100px;
bottom: 100px;
background-image: url("../Images/backcity.png");
background-position: center;
}

.copyright {
font-family: HelveticaNeue;
}

这是给请求它的用户的 fiddle 。 http://jsfiddle.net/kd7nv4vb

最佳答案

我稍微修改了你的 HTML 和 CSS,得到了 this :

HTML:已添加 <span><a> :

<li>
<a href="#about">
<span>About</span>
</a>
</li>

CSS:

.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
white-space: nowrap;
color: #171581;
}

.header li a span {
transition: 0.5s ease;
border-bottom: 3px solid transparent;
}

.header li a:hover span {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}

上一个(您的代码):

.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
border-bottom: 3px solid transparent;
transition: 0.5s ease;
white-space: nowrap;
color: #171581;
}

.header li a:hover {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}

关于html - 菜单上的底部边框在 hoover 上延伸得太远,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37619007/

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