定位?浮动?自适应?
作者:林小志 来源:林小志blog 发布时间:2008-06-30 14:20:00
标签:定位,浮动,css
额……首先呢说说这个标题吧,实在不知道叫什么好,因为这个demo呢其实一个艾文王今天中午给丢给我一个图。他说这个是一个面试题,给我看看。
这样的一个图,当时我拿到手的时候只是认为这个很简单啊,不过大家不要跟一样急,下面还有艾文王的一些补充要求。
1、<h1>iVane Hwang is a nice man~</h1> 这个一定要在显示内容的第一条。比如
<body>
<div class="box">
<div class="header">
<h1>iVane Hwang is a nice man~</h1>
..........
不论你h1前面有多少个div或者其他标签,但<h1>iVane Hwang is a nice man~</h1>这个带内容的一定要显示在最前面。
2、左右两边的高度是等高的
从他的这个要求来看,主要考虑的问题还是在页面结构上,以及等高的问题。
源文件:
作者站点下载:
http://www.linxz.cn/blog2/attachments/month_0806/i2008624161511.png
(PNG格式,请用FW打开)
本站下载:<a href="https://img.aspxhome.com/file/UploadPic/20086/30/2008630142538623.png(PNG格式,请用FW打开)
本站下载:下载地址:i2008624161511.rar (583.12 KB)
看到这里如果大家自己有兴趣做的可以先暂时停止往下看了,因为我要放我的结构以及代码了,你再看下去恐怕会影响到你的思路。毕竟每个人的想法不一样,只要效果实现就OK了。
1、大概思路:h1通过定位实现,等高用背景模拟
结果:失败!
2、大概思路:h1放在内容中,不必理会,等高用负边距实现
结果:成功!
结构:
程序代码
<div id="wrapper">
<!-- header end -->
<div id="innerBox">
<div class="mainBox">
<h1>iVane Hwang is a nice man~</h1>
<p>COLORADO SPRINGS, Colo. - As Barack Obama broadens his outreach to evangelical voters, one of the movement's biggest names, James Dobson, accuses the likely Democratic presidential nominee of distorting the Bible and pushing a "fruitcake interpretation" of the Constitution.</p>
<h2>ADVERTISEMENT</h2>
<p>The criticism, to be aired Tuesday on Dobson's Focus on the Family radio program, comes shortly after an Obama aide suggested a meeting at the organization's headquarters here, said Tom Minnery, senior vice president for government and public policy at Focus on the Family.</p>
<p>The conservative Christian group provided The Associated Press with an advance copy of the pre-taped radio segment, which runs 18 minutes and highlights excerpts of a speech Obama gave in June 2006 to the liberal Christian group Call to Renewal. Obama mentions Dobson in the speech.</p>
<div class="banner"><img src="images/banner.jpg" alt="banner" /></div>
</div>
<div class="sider">
<div class="logo">LOGO</div>
<div class="crumb"><a href="#" title="">Home</a> <span>|</span> <a href="#" title="">Contac Us</a></div>
<h3>menu</h3>
<ul>
<li><a href="#" title="menu1">menu1</a></li>
<li><a href="#" title="menu2">menu2</a></li>
<li><a href="#" title="menu3">menu3</a></li>
<li><a href="#" title="menu4">menu4</a></li>
<li><a href="#" title="menu5">menu5</a></li>
<li><a href="#" title="menu6">menu6</a></li>
</ul>
</div>
</div>
<!-- mainBox end -->
<div id="footer">
<p class="copyright">Copyright iVane Hwang © 2008 </p>
</div>
<!-- footer end -->
</div>
样式:
程序代码
* {margin:0;padding:0;}
body {font:normal 12px/1.5em Verdana,Lucida, Arial, Helvetica, sans-serif;background:#670000 url(images/bg.gif) 0 0 repeat-x;}
#wrapper {position:absolute;top:40px;left:50%;width:780px;height:auto;min-height:200px !important;margin-left:-390px;z-index:2;}
.crumb {position:absolute;top:0;right:0;width:610px;height:28px;padding-right:8px;line-height:28px;text-align:right;color:#FFFFFF;border:1px solid #010000;background:url(images/crumb_bg.gif) 0 0 repeat-x;z-index:5;}
.crumb a {color:#FFFFFF;}
#innerBox {width:780px;height:auto;overflow:hidden;zoom:1;margin-top:36px;}
#innerBox h1 {width:618px;height:60px;line-height:60px;text-indent:20px;font-size:20px;font-weight:bold;font-family:Georgia;color:#9A0000;background:#FFF4E1;z-index:6;}
.mainBox {float:right;width:618px;height:auto;overflow:hidden;zoom:1;padding:155px 0 100px;border:1px solid #010000;border-bottom-color:#D1C8B8;background:#ECE2D0;}
.banner {position:absolute;top:29px;right:0;border:1px solid #010000;border-bottom:0;}
.mainBox p {width:auto;height:auto;overflow:hidden;zoom:1;padding:15px 15px 0;font-size:14px;color:#333333;line-height:1.5;}
.mainBox h2 {width:auto;height:30px;line-height:30px;text-indent:15px;margin-top:15px;}
.sider {float:left;width:160px;margin-bottom:-2000px;padding-bottom:2000px;margin-top:85px;background:#BEAF95;}
.logo {position:absolute;top:40px;left:0;width:160px;height:30px;line-height:30px;text-align:center;font-size:18px;font-weight:bold;}
.sider h3 {display:none;}
.sider ul {width:160px;height:auto;overflow:hidden;zoom:1;border-top:1px solid #D1C8B8}
.sider ul li {width:160px;height:30px;line-height:30px;text-indent:20px;background:url(images/menu_bg.gif) 0 0 no-repeat;}
.sider ul li a {font-size:14px;font-weight:bold;text-decoration:none;color:#690000;}
.sider ul li a:hover {color:#FFFFFF;}
#footer {width:780px;height:30px;line-height:30px;text-align:center;}
.copyright {color:#ECE2D0;}


猜你喜欢
- 这段时间告诉项目需要,用到了vue。刚开始搭框架的时候用的是vue-resource后面看到官方推荐axios就换过来了 顺便封装了一下 /
- 前言SVG可以算是目前最最火热的图像文件格式了,它的英文全称为Scalable Vector Graphics,意思为可缩放的矢量图形。它是
- --查询 SELECT tp.tp_id, tp.tpmc, tp.leveid, tp.tpdz, tp.jgm, tp.scsj, tp
- 点乘和矩阵乘的区别: 1)点乘(即“ * ”) ---- 各个矩阵对应元素做乘法若 w 为 m*1 的矩阵,x
- 4 月 27 日,GitHub 趋势榜第 3 位是一个用 Python 编码实现的算法库,Star 数早已达到 26000+链接:https
- 项目介绍:Golang100行代码实现高并发聊天室,其中实现的功能有:上下线广播,私聊,用户改名,超时强踢,在线用户检测等在开始项目前,我们
- 由于要学习搭建服务器和数据库,所以最近开始自学sql语言了,至于写数据库就用比较基础的Mysql数据库了,虽然Mysql已经被互联网公司所淘
- 这是一个给新手学习代码的帖子,包含以下内容:如何使用UBB代码,如何用js与剪贴板交互,如何使用textRange对象,如何使用自定义的快捷
- 网页可以说是网站构成的基本元素。当我们轻点鼠标,在网海中遨游,一幅幅精彩的网页会呈现在我们面前,那么,网页的精彩与否的因素是什么呢?色彩的搭
- SQL Server 数据库定时自动备份,供大家参考,具体内容如下在SQL Server中出于数据安全的考虑,所以需要定期的备份数据库。而备
- 如下所示:def softmax(logits, axis=None, name=None, dim=None): ""
- 目录实验环境准备API 寻找 && 提取代码实现项目链接我身边的很多小伙伴们在朋友圈里面晒着出去游玩的照片,简直了,人多的不
- 1.认为FindControl方法寻找的范围是给定Control的后代控件。 <form id="form1" r
- 一、前提1、MySQL版本信息:MySQL版本:8.0.27注意:其他版本(主要5.x版本未验证)2、表字段:定义列CREATE TABLE
- 测了一下django、flask、bottle、tornado 框架本身最简单的性能。对django的性能完全无语了。django、flas
- 前言一个非常神秘的魔术方法。这个方法非常不起眼,用途狭窄,我几乎从未注意过它,然而,当发现它可能是上述“定律”的唯一例外情况时,我认为值得再
- 常见到网上博文有错误理论,包括身边很多朋友都曾认同“可访问性(Accessibility)是为残障人士准备”的观点。其实在互联网技术领域远不
- Python中的正则表达式要用到re模块,下面先介绍一下正则表达式需要用到的特殊字符和说明常用的RegEx基础语法语法说明\d匹配一个数字字
- 示例:mysql> DELIMITER //mysql> CREATE PROCEDURE `statis`()
- 前言相信大家在工作无聊时,总想掏出手机,看看微博热搜在讨论什么有趣的话题,但又不方便直接打开微博浏览,今天就和大家分享一个有趣的小爬虫,定时