【问题标题】:CSS Div PositioningCSS div 定位
【发布时间】:2010-09-21 06:01:43
【问题描述】:

我正在尝试构建一个最小宽度为 1024 像素的两列标题。当查看者的屏幕小于 1024 像素时,我希望将网站右侧的窗口切掉,但我不断得到奇怪的结果,比如左侧移入。提前致谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Dynamic Drive: CSS Liquid Layout #2.1- (Fixed-Fluid)</title>
<style type="text/css">
body{
    margin:0;
    padding:0;
    background-image:url(images/bground.jpg);
    background-repeat:repeat-x;
}
#contentwrapper{
float: left;
width: 100%;
min-width:1024px;
background-image:url(images/header_middle.jpg);
    background-repeat:no-repeat;
    background-position:center top;
}

#contentcolumn{
margin-left: 351px; /*Set left margin to LeftColumnWidth*/
background-image:url(images/header_right.png);
    background-repeat:no-repeat;
    height:318px;
    background-position:right;
}

#leftcolumn{
float: left;
width: 351px; /*Width of left column*/
margin-left: -100%;
background-image:url(images/header_left.png);
    background-repeat:no-repeat;
height:300px;
}


</style>

</head>
<body>
  <div id="contentwrapper">
<div id="contentcolumn"></div>
</div>

<div id="leftcolumn">

</div>

</body>
</html>

【问题讨论】:

    标签: css html


    【解决方案1】:

    试试这个

    CSS

    div.wrapper {
        width: 100%;
        min-width: 1024px;
    }
    div.one {
        width: 300px;
        float: left;
        height: 300px;
    }
    div.two {
        height: 300px;
    }
    

    HTML

    <div class="wrapper">
        <div class="one">The left column</div>
        <div class="two">The right column</div>
    </div>​
    

    现场示例

    http://jsfiddle.net/HKrbn/

    【讨论】:

    • 谢谢。我真的想多了。
    猜你喜欢
    • 2011-10-03
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多