css常用布局
1.一列布局
html:
<div class="header"></div>
<div class="body"></div>
<div class="footer"></div>
css:
.header{
height: 100px;
background: pink;
}
.body{
height:500px;
background: blue;
}
.footer{
height:100px;
background: #ddd;
}
2.两列布局(指定宽度)
html:
<div class="left"></div>
<div class="right"></div>
css:
.left{
width:20%;
height: 500px;
float: left;
background:#333;
}
.right{
width:80%;
height:500px;
float: left;
background: pink
}
3.双飞翼布局(中间自适应,左右列固定宽度)
html:
<div class="main">
<div class="cont"></div>
</div>
<div class="left"></div>
<div class="right"></div>
css:
.main {
float: left;
width: 100%;
height: 500px;
}
.cont {
height: 500px;
background-color: aqua;
margin-left: 300px;
margin-right: 300px;
}
.left {
float: left;
width: 300px;
height: 500px;
margin-left: -100%;
background-color: pink;
}
.right {
float: left;
width: 300px;
height: 500px;
margin-left: -300px;
background-color: yellow;
}
4.多栏布局
栅格系统,是bootstrap常用的布局模式,下列就举个简单四栏例子
html:
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
css:
.col{
width:25%;
height:500px;
float: left;
background: #ccc;
}
.col:nth-child(1){
background: red;
}
.col:nth-child(2){
background: green;
}
.col:nth-child(3){
background: black;
}
.col:nth-child(4){
background: yellow;
}
常见还有column-count、column-gap、column-rule、columns
5.弹性布局(flex)
html:
<ul>
<li><a href="#">菜单1</a></li>
<li><a href="#">菜单2</a></li>
<li><a href="#">菜单3</a></li>
<li><a href="#">菜单4</a></li>
</ul>
css:
ul{
display: flex;
height:100px;
width:100%;
}
ul li{
flex: auto;
list-style:none;
text-align:center;
border:1px solid red;
}
6.瀑布式布局
css常用布局的更多相关文章
- CSS常用布局实现方法
CSS 布局对我来说,既熟悉又陌生.我既能实现它,又没有很好的了解它.所以想总结一下,梳理一下 CSS 中常用的一列,两列,三列布局等的实现方法.本文小白,仅供参考.但也要了解下浮动,定位等. 一.一 ...
- css 常用布局
「前端那些事儿」③ CSS 布局方案 我们在日常开发中经常遇到布局问题,下面罗列几种常用的css布局方案 话不多说,上代码! 居中布局 以下居中布局均以不定宽为前提,定宽情况包含其中 1.水平居中 a ...
- CSS常用布局整理(二)
1-2-1单列变宽布局 side列定宽300px,content列变宽,尺寸是100%-300px.核心的问题就是浮动列的宽度应该等于“100% - 300px”,而CSS显然不支持这种带有减法运算的 ...
- CSS常用布局整理
固定宽度布局 1-2-1布局(浮动) <html xmlns="http://www.w3.org/1999/xhtml"> <head> <titl ...
- CSS常用布局方式-两列布局、三列布局
CSS基础 2.几种布局方式1)table布局 当年主流的布局方式,第一种是通过table tr td布局 示例: <style type="text/css"> ta ...
- html+css 常用布局
1.中间固定宽度,两侧自适应 1.1 flex布局 <!DOCTYPE html><html lang="en"> <head> <met ...
- CSS常用布局技巧 实例
末尾用省略号! white-space: nowrap; overflow: hidden; text-overflow: ellipsis; ######################## 两个i ...
- CSS常用布局学习笔记
水平居中-行内元素 如果是文字和图片这类的行内元素,则在其父级元素上加上样式:text-align:center; 水平居中-定宽块元素 div{ width:100px; margin:0 auto ...
- DIV+CSS常用网页布局技巧!
以下是我整理的DIV+CSS常用网页布局技巧,仅供学习与参考! 第一种布局:左边固定宽度,右边自适应宽度 HTML Markup <div id="left">Left ...
随机推荐
- django restframework jwt
既然要来学习jwt(json web token),那么我们肯定是先要了解jwt的优势以及应用场景--跨域认证. $ pip install djangorestframework-jwt 传统coo ...
- FreeNAS插件打造ownCloud私有云网盘
ownCloud 是一个自由开源的个人云存储解决方案,可以自由获取无需付费,但用户需要自行架设服务器,好在FreeNAS可以通过插件轻松的构建ownCloud服务器. ownCloud 分为服务器端和 ...
- 关于ehcache缓存中eternal及timeToLiveSeconds和timeToIdleSeconds的说明
今天发现开发项目启动时有警告提示:cache 'xx' is set to eternal but also has TTL/TTI set,发现是ehcache缓存设置冲突 所以决定在此mark一下 ...
- 使用Redisson实现分布式锁,Spring AOP简化之
源码 Redisson概述 Redisson是一个在Redis的基础上实现的Java驻内存数据网格(In-Memory Data Grid).它不仅提供了一系列的分布式的Java常用对象,还提供了许多 ...
- codeforces-1139 (div2)
A.如果第i个数字是偶数,总贡献就加上i #include <map> #include <set> #include <ctime> #include <c ...
- 微服务之路由网关—Nginx
Nginx 简介Nginx 是一款自由的.开源的.高性能的 HTTP 服务器和反向代理服务器,它具有有很多非常优越的特性: • 作为 Web 服务器: 相比 Apache , Nginx 使用更少的 ...
- ubuntu文件搜索统计
一.在ubuntu下如何搜索文件 1.特点:快速,但是是模糊查找,例如 找 #whereis mysql 它会把mysql,mysql.ini,mysql.*所在的目录都找出来.我一般的查找都用这条命 ...
- [再寄小读者之数学篇](2014-06-22 函数恒为零的一个充分条件 [中国科学技术大学2011年高等数学B考研试题])
设 $f(x)$ 在 $\bbR$ 上连续, 又 $$\bex \phi(x)=f(x)\int_0^x f(t)\rd t \eex$$ 单调递减. 证明: $f\equiv 0$. 证明: 设 $ ...
- Accoridion折叠面板
详细操作见代码: <!doctype html> <html> <head> <meta charset="UTF-8"> < ...
- svn 支持中文显示
https://blog.csdn.net/chentengkui/article/details/77543498 https://blog.csdn.net/bugall/article/deta ...