【问题标题】:I am trying to make two columns, but the second won't position correctly我正在尝试制作两列,但第二列的位置不正确
【发布时间】:2013-06-13 18:13:38
【问题描述】:

这是我用来制作列的 CSS

<style>
        h1{background-color:black;
            color: white;
        }
        .columnA{f
            float: left;
            width: 70%;
            margin:0;
        }
        .columnB{
            float: right;
            width:30%;
            margin: 0;

        }
        div.clear{clear:both;}


    </style>

这里是 HTML

<div class="container">

        <div class="columnA">
        Lorem ipsum dolor sit amet
        </div>
        <div class="columnB">

                Test 1<br>
                Test 2

        </div>
    </div>

看起来第二个 div 不会向上移动。我试过 float: left too。

【问题讨论】:

    标签: html css multiple-columns


    【解决方案1】:

    您有一个语法错误。将f float 更改为在.columnA 中浮动

    .columnA{
        f float: left;
        width: 70%;
        margin:0;
    }
    

    应该是

    .columnA{
        float: left;
        width: 70%;
        margin:0;
    }
    

    查看fiddle

    这是你的original code

    【讨论】:

    • 这很尴尬。谢谢你成为第二双眼睛!我觉得它不工作很愚蠢!
    • 没关系。 CSS 有时很棘手 :) 如果这有用,请接受答案。
    【解决方案2】:

    在你的 css 中有一个无关的 f

    .columnA{f
        float: left;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      相关资源
      最近更新 更多