Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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';s的位置不受其内容的影响,不设置宽度_Html_Css Float - Fatal编程技术网

Html 使浮动div';s的位置不受其内容的影响,不设置宽度

Html 使浮动div';s的位置不受其内容的影响,不设置宽度,html,css-float,Html,Css Float,我想做这个布局,div2的宽度不会受其内容的影响 ----------------------------------------- | | | div1 | | div2 | | | | ----------------------------------------- 这是我的密码: <html&g

我想做这个布局,div2的宽度不会受其内容的影响

-----------------------------------------
          |      |               |
   div1   |      |      div2     |      
          |      |               |       
-----------------------------------------
这是我的密码:

    <html>
    <body>

    <div style="background:red;height:200px;">

        <div  style="background:black;width:100px;float:left;height:100px;">

        </div>


        <div  style="background:green;height:50px;float:left;margin:10px;">
        when here the content is too much, this div will start another line, 
which is not wanted, I want this div to be float always, also , I dont know the with.
        </div>

    </div>


    <body>
    </html>

当这里的内容太多时,这个div将开始另一行,
这是不需要的,我希望这个div永远是浮动的,而且,我不知道它的用途。
那么,如何

添加css属性

max-width:100px

我有一个解决方案:制作第二个div
style=“background:green;height:50px;margin left:110px;”
如果我不知道第一个div的宽度,是否还有其他解决方案可能重复:。