1、有两个DIV,分别命名为 A 和B。A 在左边,最小高度是200px,宽度是 100px;B 
在右边,宽度适应浏览器宽度。A 和B 上边缘水平对齐,B的高度不固定,A 的高度需要 
自适应B的高度,但 A 高度最小是200px。请写出HTML 代码。 
2、有一个DIV,高度是 25px,宽度是100%,DIV内部的文字是“我的居中对齐例 
子”,要求用HTML+CSS制作出该DIV,并使内部文字水平居中且垂直居中对齐。 

解决方案 »

  1.   

    1.我很懒!不想思考了!
    2。的问题
    <style type="text/css">
      #id2{height:25;height:60px;line-height:60px;}
      </style>
    <div id="id2">
      <div align="center">我的居中对齐例</div>
    </div>
      

  2.   

    1. 让B float居左 就可以了,定义百分比。
      

  3.   

    第一题,自己修改B的高度测试<!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload=function()
    {
    var bh = document.getElementById("B").offsetHeight;
    if(bh>200)
    {
    document.getElementById("A").style.height=bh;
    }
    }
    </script>
    </head>
    <style type="text/css">
    *{
    margin:0;
    }
    #A
    {
    width:100px;
    float:left;
    height:200px;
    background:#cf9;
    }
    #B
    {
    margin-left:100px;
    height:200px;
    background:#ffa;
    }
    </style>
    <body>
    <div id="A">A</div>
    <div id="B">B</div>
    </body>
    </html>
    第二题<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <style type="text/css">
    .A{
    width:100%;
    height:25px;
    line-height:25px;
    BACKGROUND: #9ff;
    }
    </style>
    <body>
    <div class="A" align="center">asdfsadfasdfasdfsd</div>
    </body>
    </html>