有关于css的四种布局
四种布局
- (1)、左右两侧,左侧固定宽度200px,
右侧自适应占满。
- (2)、左中右三列,左右个200px固定,中间自适应占满。
- (3)、上中下三行,头部200px高,底部200px高,中间自适应占满。
- (4)、上下两部分,底下这个固定高度200px,如果上面的内容少,那么这个footer就固定在底部,如果内容多,就把footer挤着往下走。
一、第一种
图片如下:(左右两侧,左侧固定宽度200px,右侧自适应占满)
代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>布局1</title>
<link rel="stylesheet" href="dio.css"/>
</head>
<body>
<div class="first"></div>
<div class="second"></div>
</body>
</html>
.first,.second{height:100px;}
.first{
width:200px;
background-color:yellow;
float:left;
}
.second{
background-color:red;
position:absolute;
right:0px;
left:200px;
width:100%;
}x
二、第二种
图片如下:(上中下三行,头部200px高,底部200px高,中间自适应占满)
代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>布局2</title>
<link rel="stylesheet" href="dio2.css"/>
</head>
<body>
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</body>
</html>
.left,.center,.right{height:400px;}
.left{
width:200px;
background-color:yellow;
float:left;
}
.center{
background-color:red;
position:absolute;
right:200px;
left:200px;
}
.right{
width:200px;
float:right;
background-color:green;
}
三、第三种
图片如下:上中下三行,头部200px高,底部200px高,中间自适应占满
代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>布局3</title>
<link rel="stylesheet" href="dio3.css"/>
</head>
<body>
<div class="top"></div>
<div class="center"></div>
<div class="bottom"></div>
</body>
</html>
body{margin:0px;}
.top{
width:100%;
height:200px;
position:absolute;
background:red;
}
.center{
width:100%;
position:absolute;
background:blue;
top:200px;
bottom:200px;
}
.bottom{
width:100%;
height:200px;
position:absolute;
bottom:0px;
background:black;
}
四、第四种
图片如下:上下两部分,底下这个固定高度200px,如果上面的内容少,那么这个bottom就固定在底部,如果内容多,就把bottom挤着往下走。
代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>布局4</title>
<link rel="stylesheet" href="dio4.css"/>
</head>
<body>
<div class="top">
aijefoaiejfoaiejfaio<br/>
........
</div>
<div class="bottom"></div>
</body>
</html>
html{
height:100%;
}
body{
margin:0px;
min-height:100%;
position:relative;
background:red;
}
.top{
padding-bottom:300px;
}
.bottom{
position:absolute;
width:100%;
height:200px;
background:black;
bottom:0px;
left:0px;
}
若有错误请及时通知
有关于css的四种布局的更多相关文章
- Android开发之基本控件和详解四种布局方式
Android中的控件的使用方式和iOS中控件的使用方式基本相同,都是事件驱动.给控件添加事件也有接口回调和委托代理的方式.今天这篇博客就总结一下Android中常用的基本控件以及布局方式.说到布局方 ...
- Vscode部分快捷键 Ps的简单使用 less中的除法问题 H5 四种布局
vscode 部分快捷键 ctrl+/ 注释ctrl+回车 光标下移alt+shift+上下箭头 将本行代码向上或向下复制ul>li 自动写alt ,鼠标一直点,就会有很多光标,可以一起写ctr ...
- 页面中CSS的四种引入方式的介绍与比较
转自:https://blog.csdn.net/qq_38689666/article/details/79039392 一:行内式 <p style="color:red" ...
- Android学习笔记_3_四种布局
Android布局是应用界面开发的重要一环,在Android中,共有四种布局方式, 分别是:FrameLayout( 帧布局 ).LinearLayout (线性布局).TableLayout(表格布 ...
- 《网页设计基础——CSS的四种引入方式详解》
网页设计基础--CSS的四种引入方式详解 一.行内式: 规则: 1. 行内式是所有样式方法中最为直接的一种,它直接对HTML的标记使用style属性,然后将CSS代码直接写在其中. 格 ...
- CSS的四种引入方式
1.使用link标签引入css文件: <head> <link rel="stylesheet" type="text/css" href=& ...
- HTML中引入CSS的四种常用方法及各自的缺点
在HTML中引入CSS的方法主要有四种,它们分别是行内式.内嵌式.链接式和导入式. 1.行内式 行内式是在标记的style属性中设定CSS样式.这种方式没有体现出CSS的优势,不推荐使用.格式如下: ...
- Android-基本控件和详解四种布局方式
转自:https://www.cnblogs.com/ludashi/p/4883915.html 一.常用基本控件 1.TextView 看到Android中的TextView, 我不禁的想到了iO ...
- sess文件编译输出css的四种方式以及使用
sess文件输出css有下面四种方式: :nested(嵌套) :compact(紧凑) :expanded(展开) :compressed(压缩) 如何使用: sass --watch style. ...
随机推荐
- Hibernate:More than one row with the given identifier was found解决办法
今天写一个Action 通过 HQL 查询一个表 出现异常 “More than one row with the given identifier was found” 问题原因: 数据库出现数据异 ...
- codeforces 559D Randomizer
题意简述: 在一个格点图中 给定一个凸$n$边形(每个定点均在格点上),随机选择其中一些点构成一个子多边形, 求子多边形的内部点个数的期望. ----------------------------- ...
- 笔记:JFB 部署新环境,要更改的参数清单列表
ylbtech-笔记:JFB 部署新环境,要更改的参数清单列表 1. Web.config返回顶部 2. JS返回顶部 1./m/js/utils.js var utils = {} 序号 参数 ...
- lombda 使用记录
,,,}; String str1 = Arrays.stream(arr).boxed().map(i -> i.toString()) //必须将普通数组 boxed才能 在 map 里面 ...
- Flask学习之旅--分页功能:分别使用 flask--pagination 和分页插件 layPage
一.前言 现在开发一个网站,分页是一个很常见的功能了,尤其是当数据达到一定量的时候,如果都显示在页面上,会造成页面过长而影响用户体验,除此之外,还可能出现加载过慢等问题.因此,分页就很有必要了. 分页 ...
- 仿移动端触摸滑动插件swiper,的简单实现
/** * @author lyj * @Date 2016-02-04 * @Method 滑动方法 针对一个大容器内部的容器做滑动封装 * @param * args args.swipeDo ...
- C#后台将string="23.00"转换成int类型
在C# 后台将String类型转换成int 有以下几种方法: (1) int.TryParse(string); (2) Convert.Toint32(string); (3) (int)stri ...
- Codeforces 500D New Year Santa Network(树 + 计数)
D. New Year Santa Network time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- C#@字符的使用
一,在字符串中的使用 //当在字符串前面加上一个@字符的时候,我们就可以把一个字符串定义在多行 // 编译器不会再去识别字符串中的转义字符 // 如果需要在字符串中表示一个双引号的话,需要使用两个双引 ...
- Java 编写过滤手机号码或者固定电话的工具类
以下是分享自己编写的用于过滤手机号码.固定电话.黑名单的工具类TelCheckUtils, import java.util.HashSet; import java.util.Set; import ...