Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 两个div不会嵌套在父div中_Html_Css - Fatal编程技术网

Html 两个div不会嵌套在父div中

Html 两个div不会嵌套在父div中,html,css,Html,Css,我在父div中有两个div,但是当我检查页面时,这两个div不在容器中,即使我将该div包装在其他两个div上 我想将特征添加到父div,而不是单独添加每个div 建议 <!DOCTYPE html> <head> <title>Lavu Explore</title> <link rel="stylesheet" type="text/css" href="styles_sample.css">

我在父div中有两个div,但是当我检查页面时,这两个div不在容器中,即使我将该div包装在其他两个div上

我想将特征添加到父div,而不是单独添加每个div

建议

<!DOCTYPE html>
    <head>
    <title>Lavu Explore</title>
        <link rel="stylesheet" type="text/css" href="styles_sample.css">
    </head> 
    <body>
        <div id="sell_section">
            <h2>Sell, Manage, & Market in one easy system</h2>
            <hr class="hr_1">
            <div class="box1">
                <img id ="terminal_img" src="http://i.imgur.com/D5T6lY1.png">
            </div>
            <div class="box1">
                <p style="text-align:left">Choosing a new Point of Sale (POS) is an opportunity. Lavu   is not just accepting payments - Lavu is business management on the iPad. Upgrade your business with the Cloud POS system that was developed specifically for the restaurant / hospitality industry. Lavu has the tools you need to improve efficiency and the bottom line. Love your business.</p>
            </div>

        </div>
     </body>
</html>

您没有在doctype之后插入html开始标记,它应该看起来有点像这样

<!doctype html>
<html>
<head>
...
</head>
<body>
...
</body>
</html>

+约翰尼的答案是1,而且标记有点不正常:


您已将样式规则添加到.hr_1元素中,而您似乎希望将它们添加到“销售”部分-这是包装部门的id。

我很难准确理解您想要的是什么。根据我的理解,你可能想在你的sell_分区中添加一个边框或背景色。在不同的大小上,样式没有像你希望的那样应用?如果是这样,那么罪魁祸首是因为您正在浮动您的子/嵌套div。一开始可能有点难以理解。这绝对是需要一点实践和知识才能完全理解的概念之一

下面是漂浮物体时发生的情况:

当一个元素被浮动时,它将被从该元素的正常流动中取出 文件

这是什么意思?如果您有此结构:

内部的 内部的 以及以下CSS:

.外部{ 背景色:红色; } .内部{ 浮动:左; 宽度:50%; } .outer的背景色将不可见,因为子DIV是浮动的,并且不占用其父DIV内的任何空间。尽管父DIV内的其他元素也浮动或不随父DIV一起浮动


解决方案是什么?最流行的是as。将其应用于包含浮动元素的元素,它将表现为这些元素没有浮动并占用空间。

我找到了问题的答案!我没有意识到浮动元素不会占用div中的空间。所以为了纠正它,我在容器中添加了overflow:auto。这彻底解决了问题。现在,我可以将边框和背景添加到我的div中,而不必奇怪它们为什么不拉伸整个容器的长度。

它们都在我的父级中。还有,这和你的上一个问题有什么不同?两个方框1在sell_部分内。问题是什么?我对这个网站很陌生,所以因为我没有得到答案,我想我应该重新措辞,把问题缩短。最好的建议总是正确地格式化你的代码。这样可以帮你省去很多麻烦。
<!doctype html>
<html>
<head>
...
</head>
<body>
...
</body>
</html>