首页 \ 问答 \ CSS Div Positioning - 打破包装纸高度(CSS Div Positioning - Breaks wrapper height)

CSS Div Positioning - 打破包装纸高度(CSS Div Positioning - Breaks wrapper height)

当我将div放在其他div中时,我有一个不寻常的问题,我有我的主,一个孩子和两个(孙子),现在为了孩子的高度调整到孙子我已经通过浮动定位他们,浮动左和右浮,我的孩子定位绝对,现在我的主要宽度为980px,并以0自动边距为中心,一切似乎工作正常...我注意到我的主要没有高度它是0px,孩子是很好,高度适当调整浮动等,但我的min没有高度,如果我把它取出定位到屏幕的左边,我怎么会得到主要识别孩子,然后识别孙子,请帮助我已经尝试过清楚:既清楚又清楚:自动无济于事

CSS:

#wrapper {

    margin: 0 auto;
    width: 980px;

}

#wall {

    width: 980px;
    position: absolute;
    box-shadow: 0px 0px 10px 0px;
    border-radius: 50px;    

}

#left {

    width: 610px;
    padding: 15px;
    float: left;

}
#leftimg {

    border-radius: 35px;
    float: right;
    width: 300px;
    height: 200px;
    padding: 8px;

}
#right {

    border: 1px solid black;
    width: 310px;
    left: 645px;
    padding: 5px;
    float: right;

}

footer {

    text-align: center;
<!DOCTYPE html>

    <h1>Top Tips for your C.V</h1>
    <p>Follow these tips, No messing straight to the point</p>
    <img src="web-pics/check.png" alt="checksheet"/>

    <nav>
        <ul>

            <li><a href="#">Home</a></li>
            <li><a href="#">page 1</a></li>
            <li><a href="#">page 2</a></li>
            <li><a href="#">page 3</a></li>

        </ul>
    </nav>

</header>

<div id="wrapper">

    <div id="wall">

        <div id="right">

            <h2><u>Interactive</u></h2>

        <p>aaaaaaaaaaaa aaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaaaaaa
        aaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaa
        aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaa
        aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaa
        aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
        aaaaaaaa aaaaaaaaaaaaaaaaa  aaaaaaaaaaaaa aaaaaaaaaa aaa
        aaaaaaaa aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaa
        aaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa
        aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa   aaaaaaaaaaaaaaaaaaa
        aaaaaaaaaaaa aaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaaaaaa
        aaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaa
        aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaa
        aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaa
        aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
        aaaaaaaa aaaaaaaaaaaaaaaaa  aaaaaaaaaaaaa aaaaaaaaaa aaa
        aaaaaaaa aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaa
        aaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa
        aaa
        </p>            

        </div>


        <div id="left">
        <h1><u>Why do we need a CV?</u></h1>

            <img src="web-pics/despair.jpg" alt="Despair" id="leftimg" />

            <p>

                Believe it or not, some people do not actually have a C.V, They believe that it is too much effort
                and that it is not worth the time putting one together. Well this could not be further from the truth,
                Indeed an employer will only look at your C.V briefly, so you may ask yourself what is the point in putting
                all that information on there if they are not going to read it properly. An employer is looking for something
                that will catch their eye, then they skim it over a little bit more, they look at your previous experience,
                and if they are still looking, they will want your contact details. A C.V is the first potential step into employment,
                Get this right and you may have yourself an Interview.                  

            </p>

            <h2><u>C.V Layout</u></h2>

            <p>

                The most important thing about your C.V is not so much the content, but how you have your layout.
                This is at least to start with, Remember that it needs to catch the eye of the person reading it.
                Unless you are applying for a role as a graphic designer, do not insert pictures, colours or other
                funny gimmicks, it needs to catch their eye and look professional. Use the page to your advantage though,
                The paper is white, the font is black, this can be a dull setting to start off with, why can't you add any
                colour to it, Think of it like this, you can add as much colour to it and images and other funny captions,
                but if the content is not as fulfilling as the colours, Then the employer may wish to employ someone who has
                taken the time to make their C.V Content an easier read, it can be difficult to read a C.V if it has clashing colours.

            </p>


        </div>


     </div>

</div>


<footer>
<br />
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">

</footer>


I am having an unusual problem while positioning divs inside other divs, I have my main, a child and two ( grandchilds ), Now for the height of the child to adjust to the grandchild i have positioned them via float, Float left and float right,and my child is positioned absolute, now my main has a width of 980px and is centred with margin 0 auto, everything seems to work fine... I have noticed my main does not have a height it is at 0px, the child is fine, height adjusts to the floats properly etc but my min has no height, if i take it out the positioning goes to the left of the screen, How would i get the main to recognise the child, which then recognises the grandchildren, Please help i have tried clear: both and clear: auto to no avail

CSS:

#wrapper {

    margin: 0 auto;
    width: 980px;

}

#wall {

    width: 980px;
    position: absolute;
    box-shadow: 0px 0px 10px 0px;
    border-radius: 50px;    

}

#left {

    width: 610px;
    padding: 15px;
    float: left;

}
#leftimg {

    border-radius: 35px;
    float: right;
    width: 300px;
    height: 200px;
    padding: 8px;

}
#right {

    border: 1px solid black;
    width: 310px;
    left: 645px;
    padding: 5px;
    float: right;

}

footer {

    text-align: center;
<!DOCTYPE html>

    <h1>Top Tips for your C.V</h1>
    <p>Follow these tips, No messing straight to the point</p>
    <img src="web-pics/check.png" alt="checksheet"/>

    <nav>
        <ul>

            <li><a href="#">Home</a></li>
            <li><a href="#">page 1</a></li>
            <li><a href="#">page 2</a></li>
            <li><a href="#">page 3</a></li>

        </ul>
    </nav>

</header>

<div id="wrapper">

    <div id="wall">

        <div id="right">

            <h2><u>Interactive</u></h2>

        <p>aaaaaaaaaaaa aaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaaaaaa
        aaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaa
        aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaa
        aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaa
        aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
        aaaaaaaa aaaaaaaaaaaaaaaaa  aaaaaaaaaaaaa aaaaaaaaaa aaa
        aaaaaaaa aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaa
        aaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa
        aaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa   aaaaaaaaaaaaaaaaaaa
        aaaaaaaaaaaa aaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaaaaaa
        aaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaa
        aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaa
        aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaa
        aaaaaaaaa aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaa
        aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa
        aaaaaaaa aaaaaaaaaaaaaaaaa  aaaaaaaaaaaaa aaaaaaaaaa aaa
        aaaaaaaa aaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaa
        aaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaa
        aaa
        </p>            

        </div>


        <div id="left">
        <h1><u>Why do we need a CV?</u></h1>

            <img src="web-pics/despair.jpg" alt="Despair" id="leftimg" />

            <p>

                Believe it or not, some people do not actually have a C.V, They believe that it is too much effort
                and that it is not worth the time putting one together. Well this could not be further from the truth,
                Indeed an employer will only look at your C.V briefly, so you may ask yourself what is the point in putting
                all that information on there if they are not going to read it properly. An employer is looking for something
                that will catch their eye, then they skim it over a little bit more, they look at your previous experience,
                and if they are still looking, they will want your contact details. A C.V is the first potential step into employment,
                Get this right and you may have yourself an Interview.                  

            </p>

            <h2><u>C.V Layout</u></h2>

            <p>

                The most important thing about your C.V is not so much the content, but how you have your layout.
                This is at least to start with, Remember that it needs to catch the eye of the person reading it.
                Unless you are applying for a role as a graphic designer, do not insert pictures, colours or other
                funny gimmicks, it needs to catch their eye and look professional. Use the page to your advantage though,
                The paper is white, the font is black, this can be a dull setting to start off with, why can't you add any
                colour to it, Think of it like this, you can add as much colour to it and images and other funny captions,
                but if the content is not as fulfilling as the colours, Then the employer may wish to employ someone who has
                taken the time to make their C.V Content an easier read, it can be difficult to read a C.V if it has clashing colours.

            </p>


        </div>


     </div>

</div>


<footer>
<br />
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">

</footer>


原文:https://stackoverflow.com/questions/27280239
更新时间:2023-12-15 16:12

最满意答案

将它们移动到数组中,对该数组进行排序,然后使用该数组作为目的。

这是我通过Google 找到的解决方案 :

var maxSpeed = {
    car: 300, 
    bike: 60, 
    motorbike: 200, 
    airplane: 1000,
    helicopter: 400, 
    rocket: 8 * 60 * 60
};
var sortable = [];
for (var vehicle in maxSpeed) {
    sortable.push([vehicle, maxSpeed[vehicle]]);
}

sortable.sort(function(a, b) {
    return a[1] - b[1];
});

//[["bike", 60], ["motorbike", 200], ["car", 300],
//["helicopter", 400], ["airplane", 1000], ["rocket", 28800]]

一旦你有了数组,你可以按照你喜欢的顺序从数组中重构对象,从而完成你所做的工作。 这可以在我所知道的所有浏览器中运行,但它将取决于实现的怪癖,并且可以随时中断。 您不应该假定JavaScript对象中元素的顺序。


Move them to an array, sort that array, and then use that array for your purposes. Here's a solution:

var maxSpeed = {
    car: 300, 
    bike: 60, 
    motorbike: 200, 
    airplane: 1000,
    helicopter: 400, 
    rocket: 8 * 60 * 60
};
var sortable = [];
for (var vehicle in maxSpeed) {
    sortable.push([vehicle, maxSpeed[vehicle]]);
}

sortable.sort(function(a, b) {
    return a[1] - b[1];
});

//[["bike", 60], ["motorbike", 200], ["car", 300],
//["helicopter", 400], ["airplane", 1000], ["rocket", 28800]]

Once you have the array, you could rebuild the object from the array in the order you like, thus achieving exactly what you set out to do. That would work in all the browsers I know of, but it would be dependent on an implementation quirk, and could break at any time. You should never make assumptions about the order of elements in a JavaScript object.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)