有关于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. ...
随机推荐
- redis哨兵-5
#地址: https://www.cnblogs.com/PatrickLiu/p/8444546.html #常用架构 redis1主1从+3哨兵 实现redis高可用 #redis主从 ##### ...
- 【SpringBoot】SpringBoot的基础,全面理解bean的生命周期
前言 前段时间直接上手使用springboot开发了一个数据平台的后台部分,但是自身对于springboot的原理和过程还不是很清晰,所以反过来学习下springboot的基础. 大家都知道sprin ...
- python web自动化测试框架搭建(功能&接口)——环境搭建
自动化测试框架一般需要实现以下通用功能 执行前准备 结束后清理 执行步骤输出 执行结果输出 错误.失败截图 测试报告 发送邮件 日志 需要的软件和python第三方库有: 通用: JDK Eclips ...
- 面试题:Nginx 是如何实现高并发?常见的优化手段有哪些?
面试题: Nginx 是如何实现并发的?为什么 Nginx 不使用多线程?Nginx常见的优化手段有哪些?502错误可能原因有哪些? 面试官心理分析 主要是看应聘人员的对NGINX的基本原理是否熟悉, ...
- 利用float与overflow:hidden实现移动端两栏自适应布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- PAT 2019-3 7-4 Structure of a Binary Tree
Description: Suppose that all the keys in a binary tree are distinct positive integers. Given the po ...
- appium报错及解决方案
[已解决]mac上手动打开appium报错:“Could not find aapt Please set the ANDROID_HOME environment variable with the ...
- 存取cookies
保存: Response.Cookies["OpenID"].Value = wxobj.openid; Response.Cookies["NickName" ...
- Cocos2d-x之MessageBox
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 在cocos2d-x中使用的对话框为MessageBox,因为cocos2d-x已经包装好了:但是在一般的游戏设置中,我们不会使用coco ...
- jmeter 线程组之间传递动态变化的变量值
http://www.51testing.com/html/01/n-3725501.html https://www.jianshu.com/p/73832bae65af https://blog. ...