css布局补充一

图片边框问题

注意css布局时img图片标签默认有的浏览器有边框,所以大多时候需要去除图片的边框

CSS各种居中方法

水平居中的text-align:center 和 margin:0 auto

这两种方法都是用来水平居中的,前者是针对父元素进行设置而后者则是对子元素。他们起作用的首要条件是子元素必须没有被float影响,否则一切都是无用功。margin:0 auto
也可以被写成margin:0 auto 0 auto。不能理解的童鞋们可以自己去找找关于css缩写的内容。

垂直居中的line-height

什么?!margin在垂直居中里不起作用了?显然事情确实如此,我们仅有margin:0 auto的用法而没有auto 0的情况。至于line-height,他也是作用在父元素上,当他的值等于父元素的height值时
,内部的文字就会自动的垂直居中了。此处好像仅仅只能是文字而已,遗憾。

利用position定位来实现元素的水平和垂直居中

html代码

<div class="a">
<div class="b">
<p>这是一段文本</p>
</div>
</div>

css代码

@charset "utf-8";
*{
margin:;
padding:;
}
.a{
width: 400px;
height: 300px;
background-color: #ff3820;
/*将父元素绝对定位*/
position: relative;
}
.b{
width: 100px;
height: 50px;
background-color: #3437ff;
/*将子元素相对定位*/
position: absolute;
/*定位上面百分之五十*/
top: 50%;
/*定位左边百分之五十*/
left: 50%;
/*外边距左边负元素宽度的一半*/
margin-left: -50px;
/*外边距上负元素高度的一半*/
margin-top: -25px;
}

css布局边距问题

有的标签有默认边距,布局起来不方便,我们一般在布局的时候,会先用*将所以内外边距去除

*{
margin:;
padding:;
}

利用position: absolute;相对定位来布局管理后台

css代码

@charset "utf-8";
*{
margin:;
padding:;
overflow: hidden;
}
body{
background-color: #00C5CE;
color: #FFFFFF;
}
/*头部区域*/
.tou{
width: auto;
height: 100px;
background-color: #00C5CE;
text-align:center;
border-bottom: 4px solid #fef6ff;
}
.tou h1{
font-size: 30px;
font-weight: bold;
line-height: 100px;
}
/*左边导航区域*/
div .dh{
background-color: #5DA7AA;
width: 180px;
height: 572px;
border: 4px solid #3B5521;
border-radius: 6px;
/*将导航区域相对定位*/
position: absolute;
left:;
}
div .dh h3{
width: 182px;
height: 25px;
background-color: #2E5FC4;
font-size: 15px;
text-align: center;
line-height: 25px;
}
div .dh ul li{
background-color: #A2D3D3;
margin-top: 2px;
margin-bottom: 2px;
text-align: center;
color: #1618ff;
border: 2px solid #A2D3D3;
border-radius: 6px;
}
/*内容区域*/
div .lr{
height: 572px;
/*内容区域相对定位*/
position: absolute;
left: 190px;
right:;
bottom: 50px;
top: 104px;
color: #1618ff;
background-color: #D3EAEF;
border: 4px solid #3B5521;
border-radius: 6px;
overflow: scroll;
}
/*底部区域*/
div .db{
width: auto;
height: 42px;
background-color: #5DA7AA;
/*底部相对定位*/
position: absolute;
top: 687px;
left:;
right:;
bottom:;
text-align: center;
line-height: 42px;
}

html代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>后台管理系统</title>
<link rel="stylesheet" type="text/css" href="1.css"/>
</head>
<body>
<!--头部-->
<div class="tou">
<h1>欢迎登陆后台管理系统</h1>
</div>
<!--主体-->
<div class="zht">
<div class="dh">
<h3>导航中心</h3>
<ul>
<li>列表1</li>
<li>列表2</li>
<li>列表3</li>
<li>列表4</li>
<li>列表5</li>
</ul>
</div> <div class="lr">
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
<h1>这是内容</h1>
</div> <div class="db">
玉秀文化传播版权所有©
</div>
</div>
</body>
</html>

效果图:

利用font-awesome图片和position定位来实现文本框图标

css代码

@charset "utf-8";
.shrk{
width: 190px;
height: auto;
background-color: #194aff;
position: relative;
}
.shrk input{
width: 170px;
height: 25px;
padding-right: 25px;
border: 2px solid #2758ff;
border-radius: 6px;
}
.shrk span{
/*定位图片*/
position: absolute;
right: 0px;
top: 8px;
opacity: 0.7;
color: #2758ff;
}

html代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>输入框</title>
<link rel="stylesheet" type="text/css" href="font-awesome-4.6.3/css/font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="1.css"/>
</head>
<body>
<div class="shrk">
<input type="text"/>
<span class="fa fa-user"></span>
</div>
</body>
</html>

利用position定位来设置模态对话框

html代码

<!--网页层-->
<div class="wy">
<p>这是网页层</p>
</div> <!--遮罩层-->
<div class="mt">
</div> <!--提示层-->
<div class="tshk">
<h2>提示框</h2>
</div>

css代码

@charset "utf-8";
*{
margin:;
padding:;
}
/*网页层*/
.wy{
width: auto;
height: 2000px;
background-color: #ffd41e;
}
/*遮罩层*/
.mt{
position: fixed;
top:;
right:;
bottom:;
left:;
z-index:;
background-color:black;
opacity: 0.8;
}
/*提示层*/
.tshk{
width: 400px;
height: 300px;
background-color:aliceblue;
position: fixed;
top: 50%;
left: 50%;
z-index:;
margin-left: -200px;
margin-top: -150px;
}

布局购物商城的购买数量加减框

html代码

<div class="a">
<div class="b">-</div>
<div class="c">
<input type="text" value="1"/>
</div>
<div class="d">+</div>
</div>

css代码

@charset "utf-8";
*{
margin:;
padding:;
}
.a{
width: 150px;
height: 30px;
margin-top: 10px;
margin-left: 10px;
border: 1px solid #C6C6C6;
cursor: pointer;
}
.b{
width: 30px;
height: 30px;
background-color: #C6C6C6;
border-right: 1px solid #9B9898;
text-align: center;
line-height: 30px;
font-size: 20px;
float: left;
}
.c{
width: 88px;
height: 30px;
float: left;
}
.c input{
width: 88px;
height: 30px;
border:;
text-align: center;
line-height: 30px;
}
.d{
width: 30px;
height: 30px;
background-color: #C6C6C6;
border-left: 1px solid #9B9898;
text-align: center;
line-height: 30px;
font-size: 20px;
float: right;
}

第八十五节,css布局补充一的更多相关文章

  1. 第三百八十五节,Django+Xadmin打造上线标准的在线教育平台—登录功能实现,回填数据以及错误提示html

    第三百八十五节,Django+Xadmin打造上线标准的在线教育平台—登录功能实现 1,配置登录路由 from django.conf.urls import url, include # 导入dja ...

  2. 第二百八十五节,MySQL数据库-MySQL函数

    MySQL数据库-MySQL函数 1.MySQL内置函数 SELECT执行函数,后面跟要执行的函数 CHAR_LENGTH(str)函数:返回字符串的字符长度 -- CHAR_LENGTH(str)函 ...

  3. 第一百八十五节,jQuery,Ajax 表单插件

    jQuery,Ajax 表单插件 学习要点: 1.核心方法 2.option 参数 3.工具方法 传统的表单提交,需要多次跳转页面,极大的消耗资源也缺乏良好的用户体验.而这款 form.js 表单的 ...

  4. 第三百八十六节,Django+Xadmin打造上线标准的在线教育平台—HTML母版继承

    第三百八十六节,Django+Xadmin打造上线标准的在线教育平台—HTML母版继承 母板-子板-母板继承 母板继承就是访问的页面继承一个母板,将访问页面的内容引入到母板里指定的地方,组合成一个新页 ...

  5. 第三百八十四节,Django+Xadmin打造上线标准的在线教育平台—路由映射与静态文件配置以及会员注册

    第三百八十四节,Django+Xadmin打造上线标准的在线教育平台—路由映射与静态文件配置以及会员注册 基于类的路由映射 from django.conf.urls import url, incl ...

  6. 第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解

    第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解 信号一般使用信号分发器dispatcher.connect(),来设置信号,和信号触发函数,当捕获到信号时执行 ...

  7. 第三百一十五节,Django框架,CSRF跨站请求伪造

    第三百一十五节,Django框架,CSRF跨站请求伪造  全局CSRF 如果要启用防止CSRF跨站请求伪造,就需要在中间件开启CSRF #中间件 MIDDLEWARE = [ 'django.midd ...

  8. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  9. centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节课

    centos  lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress  安装phpmyadmin  定时备份mysql两种方法  第二十五节 ...

随机推荐

  1. 【C#】Switch datatype between object and byte[]

    This sample shows how to turn object to byte[], as well as turn byte[] to object. So,I can turn any ...

  2. 概述java语言

    1.java语言是什么? java是一门面向对象的高级语言,它吸收了c++语言的各种优点,还摒弃了C++里难以理解的多继承和指针等概念,因此Java语言具有功能强大和简单易用两个特征. 2.java语 ...

  3. KB2533623 下载

    服务器上要部署.NET Core 的环境, 先要在服务器上安装Core SDK.直达连接 下载安装一切顺利: 下面开始检验是否正确安装了↓ 运行→cmd→dotnet 结果报错↓ Failed to ...

  4. picturefill + picture 标签 实现兼容性很棒的 响应式图片 自适应 屏幕大小

    polyfill 它是一个能够补齐浏览器兼容性问题的一个东西,使用到的<picture></picture>标签 ,并不是所有浏览器都支持,为了实现更好的兼容效果,这里就使用到 ...

  5. GNU/Linux下Freeplane的界面渲染问题

    如下图所示,思维导图软件Freeplane在GNU/Linux下默认的界面渲染效果是很差的,即便将Preferences → Appearance → Antialias设置为Antialias al ...

  6. CSS3学习之——【特殊属性】

    一.CSS3的一些特殊属性 1.1 text-shadow text-shadow曾经在css2中就出现过,但在css2.1版本中又被抛弃了,现在css3.0版本又重新捡回来了.这说明text-sha ...

  7. IOS开发自定义tableviewcell的注意点😄

    自定义tableviewcell 1.xib,nib拖控件:awakefromnib: 设置2,不拖控件:- (instancetype)initWithStyle:(UITableViewCellS ...

  8. Openjudge-NOI题库-数根

    题目描述 Description 数根可以通过把一个数的各个位上的数字加起来得到.如果得到的数是一位数,那么这个数就是数根.如果结果是两位数或者包括更多位的数字,那么再把这些数字加起来.如此进行下去, ...

  9. CodeForces 706B Interesting drink

    排序,二分. 将$x$数组从小到大排序,每次询问的时候只要二分一下位置就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000& ...

  10. Mediawiki随笔

    http://www.ibm.com/developerworks/cn/opensource/os-mediawiki/  定制wiki http://www.zzbaike.com/wiki/Me ...