网络编程
位置:首页>> 网络编程>> 网页设计>> 定位?浮动?自适应?

定位?浮动?自适应?

作者:林小志 来源:林小志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 &copy; 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;}

 

0
投稿

猜你喜欢

  • 利用空闲几天把《JavaScript权威指南》安静的读了一篇。真是一本好书呀!呵呵,这句话见的太多了。好在什么地方呢?听我慢慢道来。从开始接
  • 今天我们继续向大家介绍一款翻页效果的制作。当鼠标移动到链接上时,翻页的链接区除了有悬停效果,还会放大。这样的效果具有很强烈的效果。大家适当美
  • 关于《回访确认》这件事情,在我blog和5Gme的回复里普遍出现这么几个疑问:1、下了订单却放弃支付的心理因素是什么?2、回访电话可以促进订
  • 相信每个前端工程师都有自己喜爱的javascript框架,说情感也好,道信仰也罢,javascript框架带给人的不仅仅是便捷的开发,更有一
  • 就我个人经验来讲:除了oracle,没有比HP 客户支持中心更糟糕的体验了。刚买不到一个月的HP MINI笔记本,莫名其妙键盘上的引号键松动
  •  <script language="javascript"> functio
  • 缓动,学名为Tween,缓冲移动的简称。要想页面内容切换起来舒服,就使用淡入淡出特效,要想让页面元素动起来自然,就要使用缓动效果。这两个混合
  • 一、数字类型所谓的&ldquo;数字类&rdquo;,就是指 DECIMAL 和 NUMERIC,它们是同一种类型。它严格的
  • 自动更新统计信息的基本算法是: · 如果表格是在 tempdb 数据库表的基数是小于 6,自动更新到表的每个六个修改。 · 如果表的基数是大
  • HTML5 中 div section article 的区别刚刚开始接触 HTML5 时,对它的标签很不适应,甚至一度有点反感。尤其是对
  • 以前写JS程序的时候,经常碰到了定位的问题。但每次都看到一半,找到需要的属性就了事了。今天下了狠心,要花点时间,彻底地弄明白他。以下内容看着
  • 在新建数据库或附加数据库后,想添加关系表,结果出现下面的错误: 此数据库没有有效所有者,因此无法安装数据库关系图支持对象。若要继续,请首先使
  • 晚上突然间看到大猫的头像在闪动,速度打开一看,发现他问,以前我写button标签的时候有没有写type属性,老实的我只有诚实地告诉他,我没写
  • 下面直接记录下配置主从库的操作:(本文用的是mysql5.0以上)1.在主库建立要同步的数据库,建立主库的帐号和修改主库配置首先连接上数据库
  • 学习复杂代码的最好方法是简化:(function(win, undefined) {    var jQuery = f
  • IIS设置首先打开IIS就不用说了巴第2步右建默认网站属性第3步主目录选项卡点击第3步的配置按钮弹出窗口的设置,至此IIS设置完毕任意编辑器
  • 设计方法曾经是个很尴尬的话题,因为经常看上去很美。专业人士们动手动脚折腾一大圈,出来的结果令人大跌眼镜。也有些设计师总喜欢把方法、概念吹的特
  • 在利用javascript内置的eval函数,将json格式的字符串转换成JS对象时,需要用一对"()"先将该字符串包住
  • 本文主要介绍了ASP连接11种数据库的常用语法,详细内容请参考下文:1.Access数据库的DSN-less连接方法:set adocon=
  • 引伸阅读解读absolute与relativeposition:relative/absolute无法冲破的等级定位一直是WEB标准应用中的
手机版 网络编程 asp之家 www.aspxhome.com