热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

页脚穿过div的中间-Footerrunsthroughmiddleofdiv

Ivespentthepasttwodaystroubleshootingthisproblemformyportfoliowebsite,andhaveyetto

I've spent the past two days troubleshooting this problem for my portfolio website, and have yet to find a solution.

我花了两天时间为我的投资组合网站解决这个问题,并且还没有找到解决方案。

The basic structure of the page is a header, a wrapper for content (nav bar and content divs), and the footer. The problem is that the footer is cutting through the middle of the wrapper div, making the content run around and below the footer. I would post a screenshot, but I don't have enough reputation.

页面的基本结构是标题,内容包装器(导航栏和内容div)和页脚。问题是页脚正在切割包装div的中间,使内容在页脚的周围和下方运行。我会发布截图,但我没有足够的声誉。

It looks like the div containing the résumé info is the only one causing the problem, whereas the footer is only corresponding to the nav bar.

看起来包含简历信息的div是导致问题的唯一一个,而页脚仅对应于导航栏。

Code is below.

代码如下。

Additional info: When I tried setting the footer's position to fixed, it disappears completely from the page. I also tried removing the .wrapper div and just using the content divs. I also tried changing the positions of the divs to absolute and relative.

附加信息:当我尝试将页脚的位置设置为固定时,它会从页面中完全消失。我也尝试删除.wrapper div并只使用内容div。我也尝试将div的位置改为绝对和相对。

HTML
















    
    
            
  • Kyle Simmonds
  • Copywriting, Graphic Design and Web Development

ABOUT ME


EXPERIENCE

Gulliver's Travel

  • Social Media Intern
  • January–August '12
  • // Established and managed company's Facebook and Twitter pages
  • // Created graphics for emails and promotions

TCU Schieffer School of Journalism

  • Website Assistant
  • August '09–December '12
  • // Uploaded content onto the school's website through HTML and CSS
  • // Managed the site by keeping it free of visual and typographical errors

TCU Student Activities

  • Graphic Designer
  • September '10–December '12
  • // Designed posters for campus-wide events
  • // Created invitations and printed materials for special events

Peaceable Kingdom Retreat for Children

  • Summer Staff
  • Summer '10–'11
  • // Facilitated activities for campers including high-ropes courses (zip line and rock climbing) and pool activities
  • // Ensured a safe and fun environment for campers by being lifeguard, CPR and high-ropes certified

SKILLS

  • // Advertising
  • // Copywriting/editing
  • // Graphic Design
  • // Photoshop
  • // InDesign
  • // Illustrator
  • // Web Development
  • // HTML
  • // CSS
  • // jQuery
  • // Audio/Video Editing

EDUCATION

Texas Christian University

  • December '12
  • // BS Strategic Communication
  • // Music Minor
  • // Studies in Italian

© 2013 Kyle Simmonds. All rights reserved.

CSS

body{
font-family:'OpenSans', sans-serif;
margin:0 auto;
padding:0px;
width:100%;
height:100%;
}

a, a:hover,a:active,a:visited{
text-decoration:none;
color:#000;
}

header{
width:100%;
height:70px;
background:#000;
margin:0 auto;
padding:0px;
}

    header h1{
        margin:0 0 0 10px;
        }

    header h4{
        font-weight:300;
        margin:10px;
        }

            header ul{
                width:960px;
                margin:0px 0 0 0;
                padding:8px 0 0 50;
                overflow:hidden;
                }

            header li{
                list-style:none;
                display:inline;
                }

                    #title{
                        font-size:36px;
                        color:#fff;
                        }

                    #subtitle{
                        font-size:12px;
                        font-weight:lighter;
                        font-style:italic;
                        color:#ddd;
                        }

.wrapper{
height:100%;
width:960px;
margin:0 auto;
margin-bottom:10px;
padding:0px;
position:relative;
}

    nav{
        height:100%;
        width:300px;
        margin:0 auto;
        float:left;
        padding:10px;
        }

            nav .firstlevel{
                height:100%;
                margin:0px;
                padding:0px;
                display:block;
                border-right:solid 2px #000;
                float:left;
                }

            nav .firstlevel li{
                list-style-type:none;
                font-weight:lighter;
                font-size:16px;
                padding:10px;
                }

                    nav .secondlevel ul{
                        display:inline;
                        }

                    nav .secondlevel li{
                        font-size:12px;
                        margin:0 0 0 -30px;
                        padding:10px;
                        }

    .content{
        height:100%;
        width:600px;
        margin:10px 0 0 50;
        padding:0px;
        position:absolute;
        }

            .content p{
                font-size:12px;
                }

                hr{
                    border:0;
                    height:1px;
                    background:#aaa;
                    }

                    #resume{
                        display:inline;
                        }

                            #resume h2{
                                font-size:16px;
                                color:#aaa;
                                margin-bottom:5px;
                                padding:0;
                                }

                            #resume h4{
                                font-size:14px;
                                color:#444;
                                margin-top:15px;
                                margin-bottom:0;
                                }

                            #resume ul{
                                margin:0 0 0 0px;
                                }

                                    #jobtitle{
                                        font-weight:bold;
                                        font-size:16px;
                                        margin:3px 0 0 0;
                                        }

                                    #subhead{
                                        color:#aaa;
                                        }

                            #resume li{
                                font-size:12px;
                                list-style:none;
                                display:block;
                                margin:0;
                                padding:0;
                                }

footer{
background-color:#000;
height:6%;
width:100%;
margin:0 auto;
margin-bottom:0px;
padding:0px 0 0 0;
position:absolute;
clear:both;
}

    footer p{
        position:relative;
        font-size: 10px;
        color:#fff;
        text-align:right;
        margin:8px 10 0 0;
        }

Also, if you have suggestions for making this a better question, or for better code, please let me know. Thank you for any help.

另外,如果您有建议将此问题作为更好的问题或更好的代码,请告知我们。感谢您的任何帮助。

2 个解决方案

#1


2  

Okay, so I have a few suggestions. You can go look at the updated jsFiddle, here:

好的,我有一些建议。您可以在这里查看更新的jsFiddle:

http://jsfiddle.net/tf4cq/1/

http://jsfiddle.net/tf4cq/1/

Basically, there isn't any good reason to have .content positioned absolutely. You floated the sidebar (your nav menu), so to make sure the content lines up correctly on the left side, just add a left-padding value equal to or greater than the width of the sidebar.

基本上,没有任何充分的理由让.content绝对定位。您浮动侧边栏(导航菜单),因此要确保内容在左侧正确排列,只需添加等于或大于侧边栏宽度的左边填充值。

The reason your footer doesn't wind up where you thought it should is that the two elements above it (the nav bar and the content) are both taken out of the normal document flow as soon as you apply either float or position: absolute (or fixed, for that matter).

你的页脚没有在你想到的地方结束的原因是,当你应用浮点数或位置时,它上面的两个元素(导航栏和内容)都被从正常文档流中取出:绝对(或固定,就此而言)。

Basically, you just need to update your CSS file a bit:

基本上,您只需稍微更新CSS文件:

body{
    font-family:'Open Sans', sans-serif;
    margin:0 auto;
    padding:0;
    width:100%;
    height:100%;
}

a, a:hover, a:active, a:visited{
    text-decoration:none;
    color:#000;
}

header{
    width:100%;
    height:70px;
    background:#000;
    margin:0 auto;
    padding:0;
}

    header h1{
        margin:0 0 0 10px;
    }

    header h4{
        font-weight:300;
        margin:10px;
    }

    header ul{
        width:960px;
        margin:0;
        padding:8px 0 0 50;
        overflow:hidden;
    }

    header li{
        list-style:none;
        display:inline;
    }

#title{
    font-size:36px;
    color:#fff;
}

#subtitle{
    font-size:12px;
    font-weight:lighter;
    font-style:italic;
    color:#ddd;
}

.wrapper{
    height:100%;
    width:960px;
    margin:0 auto 10px;
    padding:0;
    position:relative;
}

nav{
    height:100%;
    width:300px;
    margin:0 auto;
    float:left;
    padding:10px;
}

    nav .firstlevel{
        height:100%;
        margin:0px;
        padding:0px;
        display:block;
        border-right:solid 2px #000;
        float:left;
    }

    nav .firstlevel li{
        list-style-type:none;
        font-weight:lighter;
        font-size:16px;
        padding:10px;
    }

    nav .secondlevel ul{
        display:inline;
    }

    nav .secondlevel li{
        font-size:12px;
        margin:0 0 0 -30px;
        padding:10px;
    }

.content{
    height:100%;
    width:600px;
    margin:10px;
    padding:0;
    padding-left:300px;
}

    .content p{
        font-size:12px;
    }

hr{
    border:0;
    height:1px;
    background:#aaa;
}

#resume{
}

    #resume h2{
        font-size:16px;
        color:#aaa;
        margin-bottom:5px;
        padding:0;
    }

    #resume h4{
        font-size:14px;
        color:#444;
        margin-top:15px;
        margin-bottom:0;
    }

    #resume ul{
        margin:0 0 0 0px;
    }

    #resume li{
        font-size:12px;
        list-style:none;
        display:block;
        margin:0;
        padding:0;
    }

#jobtitle{
    font-weight:bold;
    font-size:16px;
    margin:3px 0 0 0;
}

#subhead{
    color:#aaa;
}

footer{
    background-color:#000;
    height:6%;
    width:100%;
    margin:0 auto;
    margin-bottom:0px;
    padding:0;
    position:absolute;
    clear:both;
}

    footer p{
        position:relative;
        font-size: 10px;
        color:#fff;
        text-align:right;
        margin:8px 10 0 0;
    }

#2


1  

What I (stupidly) realized was that the DOCTYPE says html5, when html is the correct declaration. @TiesonT. thank you for helping. Changing the DOCTYPE solved the problem.

我(愚蠢地)意识到,当HTML是正确的声明时,DOCTYPE会说html5。 @TiesonT。感谢您的帮助。更改DOCTYPE解决了问题。


推荐阅读
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 本文介绍了django中视图函数的使用方法,包括如何接收Web请求并返回Web响应,以及如何处理GET请求和POST请求。同时还介绍了urls.py和views.py文件的配置方式。 ... [详细]
  • PDO MySQL
    PDOMySQL如果文章有成千上万篇,该怎样保存?数据保存有多种方式,比如单机文件、单机数据库(SQLite)、网络数据库(MySQL、MariaDB)等等。根据项目来选择,做We ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 开发笔记:Java是如何读取和写入浏览器Cookies的
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Java是如何读取和写入浏览器Cookies的相关的知识,希望对你有一定的参考价值。首先我 ... [详细]
  • 基于dlib的人脸68特征点提取(眨眼张嘴检测)python版本
    文章目录引言开发环境和库流程设计张嘴和闭眼的检测引言(1)利用Dlib官方训练好的模型“shape_predictor_68_face_landmarks.dat”进行68个点标定 ... [详细]
  • 31.项目部署
    目录1一些概念1.1项目部署1.2WSGI1.3uWSGI1.4Nginx2安装环境与迁移项目2.1项目内容2.2项目配置2.2.1DEBUG2.2.2STAT ... [详细]
  • Python爬虫中使用正则表达式的方法和注意事项
    本文介绍了在Python爬虫中使用正则表达式的方法和注意事项。首先解释了爬虫的四个主要步骤,并强调了正则表达式在数据处理中的重要性。然后详细介绍了正则表达式的概念和用法,包括检索、替换和过滤文本的功能。同时提到了re模块是Python内置的用于处理正则表达式的模块,并给出了使用正则表达式时需要注意的特殊字符转义和原始字符串的用法。通过本文的学习,读者可以掌握在Python爬虫中使用正则表达式的技巧和方法。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 移动端常用单位——rem的使用方法和注意事项
    本文介绍了移动端常用的单位rem的使用方法和注意事项,包括px、%、em、vw、vh等其他常用单位的比较。同时还介绍了如何通过JS获取视口宽度并动态调整rem的值,以适应不同设备的屏幕大小。此外,还提到了rem目前在移动端的主流地位。 ... [详细]
author-avatar
希臘神話2502873813
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有