【发布时间】:2017-06-26 16:28:47
【问题描述】:
我现在有一个灰色背景的标题,宽度为 100%,最大宽度为 1000 像素。我有一个单独的 div,其绝对位置位于我的实际标题 div 后面,当前是灰色背景,因此灰色可以超出 1000px 的限制。我希望这个灰色背景与屏幕一样大,它目前正在这样做,但我遇到的问题是,如果用户必须滚动所有灰色背景,宽度为 100%浏览器,所以我在其他地方留下了白色背景。有什么我可以做的,这样即使水平滚动也是屏幕的整个宽度?
这是一个 JSFiddle:https://jsfiddle.net/mb1brnma/1/
小提琴中的内容有点混乱,但它确实代表了如果向右滚动背景不会完全向右延伸的问题。
编辑:
HTML:
<div id="footerTopBG"></div>
<div id="footerBG"></div>
<body>
<div id="footer-container">
<div id="footer-holder">
<footer>
<section id="mid">
<div align=left class="box">
<h5>Customer Care</h5>
<ul>
<li><a href="/pages/Return-Policy.html">Return Policy</a></li>
<li><a href="/free-shipping.html">Free Shipping*</a></li>
<li><a href="/pages/Terms-And-Conditions.html">Terms & Conditions</a></li>
<li><a href="/pages/Privacy-Statement.html">Privacy Statement</a></li>
<li><a href="/pages/FCC-Wireless-Alert.html">FCC Wireless Alert</a></li>
</ul>
</div>
<div align=left class="box">
<h5>More About NLFX</h5>
<ul>
<li><a href="/pages/About-us.html">About Us</a></li>
<li><a href="http://gobos.nlfxpro.com">NLFX Pro Custom Gobo</a></li>
<li><a href="/pages/Installations.html">Installations</a></li>
<li><a href="/pages/Blog.html">Blog</a></li>
</ul>
</div>
<div align=left class="box">
<FM>
<h5>Follow NLFX</h5>
<ul id="A">
<li class="one"><a href="https://www.facebook.com/nlfxpro/"><i class="fa fa-facebook-square fa-2x" aria-hidden="true"></i></a></li>
<li class="two"><a href="https://twitter.com/NLfxPro?ref_src=twsrc%5Etfw"><i class="fa fa-twitter-square fa-2x" aria-hidden="true"></i></a></li></ul>
<ul id="B">
<li class="one"><a href="https://www.youtube.com/user/NLFXProfessional?feature=sub_widget_1"><i class="fa fa-youtube-square fa-2x" aria-hidden="true"></i></a></li>
<li class="two"><a href="https://www.instagram.com/nlfxpro/?hl=en"><i class="fa fa-instagram fa-2x" aria-hidden="true"></i></a></li>
</ul>
</FM>
</div>
<div align=left class="box">
<div id="af-form-2011966506" class="af-form"><div id="af-header-2011966506" class="af-header"><div class="bodyText"><p style="text-align: center;"><span style="font-size: 18px;white-space=nowrap;"><strong style="color: whitesmoke;">Newsletter signup!</strong></span></p></div></div><div id="af-body-2011966506" class="af-body af-standards"><div class="af-element"><div class="af-textWrap"><input id="awf_field-79641788" type="text" name="name" class="text" value="" onfocus=" if (this.value == '') { this.value = ''; }" onblur="if (this.value == '') { this.value='';} " tabindex="500" placeholder="Your Name"></div><div class="af-clear"></div></div><div class="af-element"><div class="af-textWrap"><input class="text" id="awf_field-79641789" type="text" name="email" value="" tabindex="501" onfocus=" if (this.value == '') { this.value = ''; }" onblur="if (this.value == '') { this.value='';} " placeholder="Email Address"></div><div class="af-clear"></div></div><div class="af-element"><div class="af-selectWrap"><select id="awf_field-79641790" name="custom Your Interests" tabindex="502"> <option selected="selected" class="multiChoice" value="">Select an Interest</option><option class="multiChoice" value="Dj">DJ</option><option class="multiChoice" value="House of worship">House of Worship</option><option class="multiChoice" value="Family fun center">Family Fun Center</option><option class="multiChoice" value="Live Production">Live Production</option><option class="multiChoice" value="Performance venue">Performance Venue</option><option class="multiChoice" value="Rental company">Rental Company</option></select></div><input type="hidden" name="meta_preselected_awf_field-79641790" value="---select one---"><div class="af-clear"></div></div><div class="af-element buttonContainer"><input name="submit" class="submit" type="submit" value=" Subscribe to our Newsletter! " tabindex="503"><div class="af-clear"></div></div></div></div>
</div>
</section>
<section id="bottom">
<address>
<p class="big">NLFX Professional</p>
<p>1319 Naylor Drive SE</p>
<p>Bemidji, MN 56601</p>
<p><a href="https://www.google.com/maps/place/NLFX+Professional/@47.4419595,-94.8508662,17z/data=!3m1!4b1!4m5!3m4!1s0x52b82dc7d2024257:0xd700f2707b61b267!8m2!3d47.4419559!4d-94.8486775" target="_blank">View Map</a></p>
</address>
<div class="phone">
<p class="big">Contact Us</p>
<p>Toll Free: 1-888-660-6696</p>
<p>Local: 218-444-2994</p>
<p>Email: <a href="mailto:customercare@nlfxpro.com">customercare@nlfxpro.com</a></p>
</div>
<div class="hours">
<p class="big">Store Hours</p>
<p>Monday - Friday</p>
<p>8:30am - 5:00pm</p>
</div>
<div class="copy">
Copyright © 2012 NLFX Professional
</div>
</section>
</footer>
</div>
</div>
</body>
CSS:
footer {
width: 100%;
max-width:900px;
min-width:770px;
float: left;
height:310px;
background: linear-gradient(to bottom, #9b9b9b 61.2%,#414141 61.2%);
}
footer #mid {
width: 96%;
margin: 2%;
float: left;
position: relative;
display: inline;
max-width:900px;
min-width:720px;
}
footer #mid .box {
width: 25%;
overflow: visible;
float: left;
}
footer #mid .box h5 {
overflow: hidden;
font-size: 18px;
position: absolute;
color: white;
font-weight: bold;
}
footer #mid .box ul {
width: 170px;
margin-top: 20px;
float: left;
position: relative;
}
footer #mid .box ul li a{
color: white;
display: inline-block;
padding-top: 10px;
}
footer #mid .box FM li a{
display:inline;
font-size:23px;
padding-top:0px !!important;
}
footer #mid .box FM li a:hover{
font-size: 25px;
}
footer #mid .box FM .one{
position: absolute;
text-align: right;
right:120px
}
footer #mid .box FM .two{
position: absolute;
text-align: left;
left:58px;
}
footer #mid .box FM #B{
bottom:-30px;
}
footer #mid .box FM #A{
bottom:-5px;
}
footer #mid .box FM #A li:hover{
transform: translateY(-5px);
}
footer #mid .box ul li a:hover {
color: #ccc;
transform: translate(2%);
}
#af-form-2011966506{
float: left;
margin-left: -60px;
padding:8px;
overflow: visible;
border:1px solid white;
}
#awf_field-79641790{
width:100%;
text-align: center;
vertical-align:middle;
background-color: white;
border-radius: 2.5px;
}
footer #bottom {
width: 100%;
max-width:900px;
min-width:720px;
height: auto;
float: left;
color: ghostwhite;
margin: 10px 2%;
display:inline;
}
footer #bottom address {
width: 26%;
margin-right: 50px;
float: left;
font-style: normal;
}
footer #bottom .big {
color: whitesmoke;
font-family: 'TeXGyreAdventor', sans-serif;
font-weight: bold;
font-size: 18px;
}
footer #bottom address a {
color:deepskyblue;
}
footer #bottom address a:hover {
color:skyblue;
}
footer #bottom .phone {
margin: 0;
width: 30%;
min-width: 230px;
float: left;
}
footer #bottom .phone a {
color: deepskyblue;
}
footer #bottom .phone a:hover {
color: skyblue;
}
footer #bottom .hours {
margin-left: 50px;
float: left;
width: 26%;
}
footer #bottom .copy {
width: 100%;
margin-top: 10px;
float: left;
text-align: center;
font-family: "Trebuchet MS";
color: whitesmoke;
font-size: 12px;
}
#footerBG{
background-color:#414141;
background-repeat: repeat-x;
width: 100%;
min-width:700px;
position:relative;
height: 120px;
z-index: -999999;
}
#footerTopBG{
background-color:#9b9b9b;
background-repeat: repeat-x;
width: 100%;
min-width:700px;
position:relative;
margin-top: -310px;
height: 190px;
z-index: -9999;
}
【问题讨论】:
-
请提供代码。理想情况下是带有相关 html 和 css 的 sn-p
-
@mikepa88 代码已添加。如果这还不够,我可以添加更多代码,但我相信这就是页脚的所有内容,这就是问题所在。
-
如果我取出
<body>标签,我看不出该代码有问题。这实际上是您的代码的样子吗?#footerBG在<body>标记之外?如果是这样,请不要这样做;把它移进去,看看它是否有效。如果没有,那么看看您是否可以提供一个堆栈 sn-p 来重现该问题,因为必须存在其他问题。 -
@cjl750 我的代码实际上就是这样。将它带入正文的问题是
width 100%属性使其仅与正文一样宽,最大为 1000 像素。我希望它始终是屏幕的全宽。
标签: html css background repeat