【CSS/HTML】实现可扩展性的页面布局

news/2024/10/5 14:35:36 标签: css, html, 前端

文章目录

    • 1.左右结构,左边100%;右边宽度固定
    • 2.左右结构,左边固定,右边100%
    • 3.左中右结构,左边固定,右边固定,中间100%

前面有一篇文章讲过 《html" title=css>css实现两列布局,一列固定宽度,一列宽度自适应方法》,主要是讲实现一列固定宽度,一列宽度自适应的几种方法。

下面我在总结一下一般的三种扩展布局,这儿所示的扩展布局很常规,有的童鞋会说使用column或者flex啥的布局不是很方便吗,但是你也要看它的支持程度吧,比如你在手机端使用,那当然很好,那我要兼容IE8,IE9呢?

1.左右结构,左边100%;右边宽度固定

在这里插入图片描述

html" title=css>css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#main_wrapper{float:left; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#sidebar{float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="main_wrapper">
        <div id="main"></div>
    </div>
    <div id="sidebar"></div>
</div>
<div id="footer"></div>

2.左右结构,左边固定,右边100%

在这里插入图片描述

html" title=css>css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar{float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main_wrapper{float:right; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="sidebar"></div>
    <div id="main_wrapper">
        <div id="main"></div>
    </div>
</div>

3.左中右结构,左边固定,右边固定,中间100%

在这里插入图片描述

html" title=css>css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar-l {float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main-wrapper {margin-top:10px; float:left; width:100%; margin-left:-420px; height:200px;}
#main {margin-left:438px; background:#999; height:200px;}
#sidebar-r {float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center">
    <div id="sidebar-l">这里是左边</div>
    <div id="main-wrapper">
        <div id="main">这里是中间</div>
    </div>
    <div id="sidebar-r">这里是右边</div>
</div>
<div id="footer"></div>

http://www.niftyadmin.cn/n/5690999.html

相关文章

YOLOv11改进 | 卷积模块 | 分布移位卷积DSConv替换Conv

秋招面试专栏推荐 &#xff1a;深度学习算法工程师面试问题总结【百面算法工程师】——点击即可跳转 &#x1f4a1;&#x1f4a1;&#x1f4a1;本专栏所有程序均经过测试&#xff0c;可成功执行&#x1f4a1;&#x1f4a1;&#x1f4a1; 本文介绍DSConv&#xff0c; DSConv 将…

过滤器Filter【详解】

过滤器Filter 1、 现有问题 在以往的Servlet中&#xff0c;有冗余的代码&#xff0c;多个Servlet都有重复的代码 比如编码格式设置 登录信息认证 2、 概念 过滤器&#xff08;Filter&#xff09;是处于客户端与服务器目标资源之间的一道过滤技术。 过滤器 3、 过滤器作用 执…

自然常数e的定义

参考&#xff1a; 自然常数e到底自然在哪&#xff1f;What is the Number e? 自然常数e的公式定义如下&#xff1a; e lim ⁡ n → ∞ ( 1 1 n ) n e \lim_{n \to \infty} \left(1 \frac{1}{n}\right)^n en→∞lim​(1n1​)n 可以用银行利息的复利来理解这个公式。举个例…

SVG 简介

SVG 简介 SVG(可缩放矢量图形)是一种基于XML的图像格式,用于在网页上创建二维图形。与传统的位图图像(如JPG或PNG)不同,SVG图像由直线、曲线、点和多边形等几何形状组成,这些形状可以通过数学方程来描述,因此可以无限放大而不失真。SVG格式由万维网联盟(W3C)制定,并…

解决Python使用Selenium 时遇到网页 <body> 划不动的问题

如果在使用 Selenium 时遇到网页的 <body> 划不动的问题&#xff0c;这通常是因为页面的滚动机制&#xff08;例如&#xff0c;可能使用了一个具有固定高度的容器或自定义的滚动条&#xff09;导致无法通过简单的 JavaScript 实现滚动。可以通过以下方法来解决该问题。 …

大学生就业与招聘:Spring Boot系统设计

1系统概述 1.1 研究背景 如今互联网高速发展&#xff0c;网络遍布全球&#xff0c;通过互联网发布的消息能快而方便的传播到世界每个角落&#xff0c;并且互联网上能传播的信息也很广&#xff0c;比如文字、图片、声音、视频等。从而&#xff0c;这种种好处使得互联网成了信息传…

Qt系统学习篇(6)-QMainWindow

QMainWindow是一个为用户提供主窗口程序的类&#xff0c;包含一个菜单栏(menu bar)、多个工具栏(tool bars)、多个锚接部件(dock widgets)、一个状态栏(status bar)及一个中心部件(central widget)&#xff0c;是许多应用程序的基础&#xff0c;如文本编辑器&#xff0c;图片编…

JAVA实现大写金额转小写金额

在金融行业中经常需要把大写金额转成小写金额&#xff0c;之前在一次开发中有个类似的需求&#xff0c;翻阅了好多博文&#xff0c;都没找到合适的&#xff0c;故没办法&#xff0c;就花了点时间研究并实现! 实现代码如下: private static final Character ZERO 零;private s…