这个问题是来自网站管理员Stack Exchange的migrated,因为它可以在4天前的Stack Overflow. Migrated上回答。
我正在尝试为一个学校项目创建一个假网站。到目前为止,我已经添加了一个交叉淡入淡出的图像横幅。接下来我想添加的是一个栏,您可以在其中转到不同的页面,如“食品”、“销售”等。我希望这个栏位于图像横幅的下方。但是,当我添加标签时,它们位于横幅的顶部。以前,我使用的是一个简单的图像横幅。当我添加标签时,它们像平常一样将自己定位在图像下面。但是因为我使用了多个图像和动画,它的行为不同,我不知道如何修复它。
下面是我想要的效果(但这是因为我禁用了交叉渐变)
我得到的最接近的解决方案是改变.fadein{height:1000 px},这将按钮向下移动,但我不确定这是否可行。我还改变了按钮的位置,从相对,绝对等,但没有一个给予我想要的效果。
这是我的代码。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
img {display:block}
.button {
background-color:black;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
}
.button:hover{background-color:aqua}
.header {
background-color: #DB912B;
}
p {
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
}
.blackFriday{
line-height: 40px;
height: 40px;
position: relative;
overflow: hidden;
background-color: antiquewhite z-index: 1;
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
}
/*.fadein{height:100px;}*/
/*Animated Banner*/
.fadein img {
position:absolute;
-webkit-animation-name: fade;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 12s;
animation-name: fade;
animation-iteration-count: infinite;
animation-duration: 12s;
}
@-webkit-keyframes fade {
0% {opacity: 0;}
20% {opacity: 1;}
33% {opacity: 1;}
53% {opacity: 0;}
100% {opacity: 0;}
}
@keyframes fade {
0% {opacity: 0;}
20% {opacity: 1;}
33% {opacity: 1;}
53% {opacity: 0;}
100% {opacity: 0;}
}
#f1 {
background-color: lightblue;
}
#f2 {
-webkit-animation-delay: -8s;
background-color: yellow;
}
#f3 {
-webkit-animation-delay: -4s;
background-color: lightgreen;
}
</style>
</head>
<body>
<center>
<p class="blackFriday" style="background-color:#191616; color: white; font-weight:bold;">BLACK FRIDAY SALE!</p>
</center>
<div class="fadein">
<img id="f3" src="banner1.png" width="100%" alt="">
<img id="f2" src="banner2.png" width="100%" alt="">
<img id="f1" src="banner3.png" width="100%" alt="">
</div>
<!--Buttons-->
<center>
<p style="background-color:black; position:relative;" >
<button class="button">food</button>
<button class="button">toys</button>
<button class="button">medicine</button>
<button class="button">holiday sale</button>
<button class="button">about us</button>
</p>
</center>
</body>
</html>
1条答案
按热度按时间qni6mghb1#
我稍微修正了你的代码,它完全按照你的意图工作。在这里。希望它能有所帮助!
第一个