Stackoverflow - 错误012984739276442x [英] Stackoverflow - Error 012984739276442x
问题描述
此问题已被用户删除
如果添加 code>到您的导航div它会下来,你应该删除
.header
的高度以适应内容。因此它将只适合提供的图像。这里是代码:
$(document).ready {$(#slider)。animate({left:$(。item:first)。position()。left +px,width:$(。item:first)。 width()+px},0); $(。item)。hover(function(){$(#slider)。 left:$(this).position()。left +px,width:$(this).width()+px},500);}); $ on(mouseout,function(){$(#slider)。stop(); $(#slider)。animate({left:$('#one')。position +px,width:$('#one')。width()+px},500);});});
pre class =snippet-code-css lang-css prettyprint-override> body {/ *适用于< body& tag * / margin:0px; / *将所有边的边距设置为0px * /}。container {/ *容器类* / width:100%; / *这设置宽度* / height:100%; / *这设置高度* / background-color:black; / *设置背景颜色* /}。header {/ *头类* / width:100%; background-color:#323232;颜色:白色; / *设置字体的颜色* /}。body {width:100%; height:495px; background-color:white; color:black;}。footer {width:100%; height:50px; background-color:#323232; color:white;} div {display:inline-block; float:left;}#one,#two,#three,#four {background-color:#323232; height:96px;颜色:白色; text-align:center; font-size:25px; font-family:Myriad Pro;}#slider {background-color:#ed1c24; height:10px; width:100px; position:absolute; left:0; bottom:0;}。inside {margin-left:30px; margin-right:30px; padding-top:7px; pointer-events:none; margin-top:40px;}
< script src = https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"> ;</script> ;<div class =container> <! - 这是容器 - > < div class =header> <! - 这是标题 - > < div style =float:left> <! - 这是标志 - > < img src =https://cdn.colorlib.com/wp/wp-content/uploads/sites/2/2014/02/Olympic-logo.pngheight =100px> < / div> < div style =float:right; font-size:24px; font-family:'Myriad Pro';> Above< / div& < div style =float:right; clear:right> <! - 这是导航菜单 - > < div style =position:relative> <! - 这是导航菜单的容器 - > < div id =slider>< / div> <! - 这是滑块 - > < a href =index.html>< div id =oneclass =item>< div class =inside>首页< / div>< / div>< / a> <! - 这只是其中的一个按钮 - > < a href =about.html>< div id =twoclass =item>< div class =inside>关于我们< / div>< / div> / a> < / div>< / div>< / div>< / div>< / div>< a> < / div>< / div>< / div>< / div>< / div>< a> < / div> < / div> < / div> < div class =body> <! - 这是身体 - > < / div> < div class =footer> <! - 这是脚注 - > < / div>< / div>
This question was deleted by the user
If you add a clear:both
to your navigation div it will come down and you should remove the height of your .header
to fit the content. so it will just fit the provided image. here is the code:
$(document).ready(function() {
$("#slider").animate({
"left": $(".item:first").position().left + "px",
"width": $(".item:first").width() + "px"
}, 0);
$(".item").hover(function() {
$("#slider").stop();
$("#slider").animate({
"left": $(this).position().left + "px",
"width": $(this).width() + "px"
}, 500);
});
$(".item").on("mouseout", function() {
$("#slider").stop();
$("#slider").animate({
"left": $('#one').position().left + "px",
"width": $('#one').width() + "px"
}, 500);
});
});
body{ /* Applies to the <body> tag */
margin:0px; /* Sets the margin on all sides to 0px */
}
.container{ /* The container class */
width:100%; /* This sets the width */
height:100%; /* This sets the height */
background-color:black; /* Sets the background colour */
}
.header{ /* The header class */
width:100%;
background-color:#323232;
color:white; /* The sets the colour of the font */
}
.body{
width:100%;
height:495px;
background-color:white;
color:black;
}
.footer{
width:100%;
height:50px;
background-color:#323232;
color:white;
}
div{
display: inline-block;
float:left;
}
#one, #two, #three, #four{
background-color:#323232;
height:96px;
color:white;
text-align:center;
font-size:25px;
font-family:"Myriad Pro";
}
#slider{
background-color:#ed1c24;
height:10px;
width:100px;
position: absolute;
left: 0;
bottom:0;
}
.inside{
margin-left:30px;
margin-right:30px;
padding-top:7px;
pointer-events:none;
margin-top:40px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container"> <!-- This is the container -->
<div class="header"> <!-- This is the header -->
<div style="float:left"> <!-- This is the logo -->
<img src="https://cdn.colorlib.com/wp/wp-content/uploads/sites/2/2014/02/Olympic-logo.png" height="100px">
</div>
<div style="float:right; font-size:24px; font-family:'Myriad Pro';">Above</div>
<div style="float:right; clear:right"> <!-- This is the navigation menu -->
<div style="position:relative"> <!-- This is the container of the navigation menu -->
<div id="slider"></div> <!-- This is the slider bar -->
<a href="index.html"><div id="one" class="item"><div class="inside">Home</div></div></a> <!-- This is just one of the buttons -->
<a href="about.html"><div id="two" class="item"><div class="inside">About Us</div></div></a>
<a href="apps.html"><div id="three" class="item"><div class="inside">Apps</div></div></a>
<a href="contact.html"><div id="four" class="item"><div class="inside">Contact</div></div></a>
</div>
</div>
</div>
<div class="body"> <!-- This is the body -->
</div>
<div class="footer"> <!-- This is the footer -->
</div>
</div>
这篇关于Stackoverflow - 错误012984739276442x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!