2个DIV制作十字架

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>十字架制作</title>
<style type+"text/css">
body
{
    margin:0;
    height:100%;
    width:100%;
}   
#h
{	
    width:100%;
    height:50px;
    background:red;
    position:absolute;
    top:50%;
    margin-top:-25px;	
}
#v
{
    width:50px;
    height:100%;    
    position:absolute;
    left:50%;
    margin-left:-25px;
    background:red;
}
</style>
</head>
<body>
    <div id="h"></div>
    <div id="v"></div>
</body>
</html>

刚测试时发现在IE下水平居中的DIV无法显示高度,原来IE6下的body不是100%的默认高度
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用flex布局制作十字架网页的示例代码: ```html <!DOCTYPE html> <html> <head> <title>Flex Cross Layout</title> <style type="text/css"> body { margin: 0; padding: 0; display: flex; flex-direction: column; min-height: 100vh; } header, footer { background-color: #333; color: #fff; padding: 10px; text-align: center; } main { display: flex; flex: 1; } aside { background-color: #f2f2f2; padding: 10px; flex-basis: 200px; } section { flex: 1; display: flex; flex-direction: column; } section > div { flex: 1; display: flex; flex-direction: row; } section > div > div { flex: 1; padding: 10px; } #left-top { background-color: #f2f2f2; } #left-bottom { background-color: #d9d9d9; } #right { background-color: #e6e6e6; } </style> </head> <body> <header> <h1>Header</h1> </header> <main> <aside> <h2>Aside</h2> <p>Some content here</p> </aside> <section> <div> <div id="left-top"> <h2>Left Top</h2> <p>Some content here</p> </div> <div id="right"> <h2>Right</h2> <p>Some content here</p> </div> </div> <div> <div id="left-bottom"> <h2>Left Bottom</h2> <p>Some content here</p> </div> <div id="right"> <h2>Right</h2> <p>Some content here</p> </div> </div> </section> </main> <footer> <h3>Footer</h3> </footer> </body> </html> ``` 这个示例代码使用了flex布局来实现一个十字架网页,其中header和footer分别是顶部和底部的导航栏,main是整个页面的主体部分,包括aside和section两个部分。aside是左侧的导航栏,section是右侧的内容区域,包括两个div,每个div又包括左右两个子div。这个布局可以根据实际需要进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值