CSS布局实战
1、 ul li中上图下字,图片、文字居中。
<ul>
<li>
<img src="dash.png" style="display:block;height:20px;width:20px;margin: 0 auto">
<span style="float:left;text-align:center;">Dashboard</span>
</li>
</ul>

文字换行:display:block
图片居中:margin: 0 auto
文字居中:float:left;text-align:center
2、页面遮罩的实现
z-index属性决定了元素的显示层级,z-index越大,显示层级越靠上。
opacity表示透明度。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>html 最简遮罩层</title>
<script type="text/javascript">
function showDiv(){
document.getElementById('popDiv').style.display='block';
document.getElementById('bg').style.display='block';
}
function closeDiv(){
document.getElementById('popDiv').style.display='none';
document.getElementById('bg').style.display='none';
}
</script>
</head>
<body>
<div id="popDiv" style="z-index:99;display:none;position:absolute;margin-top: 20%;margin-left: 40%;background-color: #FFF;">
分析中...<br/>
<a href="javascript:closeDiv()">关闭遮罩层</a>
</div>
<div id="bg" style="display:block;background-color: #ccc;width: 100%;position:absolute;height: 100%;opacity: 0.5;z-index: 1;"></div>
<div style="padding-top: 10%;padding-left:40%;z-index:1;">
<input type="Submit" name="" value="打开遮罩层" onclick="javascript:showDiv()" />
</div>
</body>
</html>
3、样式优先级!important
.menu_accordion .nav-first-level li div
{
background-color:#FFFFFF!important;
}
4、阻止div换行
(1)使用tbale封装div为列
(2)使用样式float:left;
(3)使用样式display:inline;
<html>
<head>
<style type="text/css">
.myrow{
border:#c3c3c3 1px solid;
height:30px;
margin:5px;
} .myfloat{
float:left;
margin:2px;
} .mydisplay{
display:inline;
margin:2px;
} .myline{
border-style:solid;
border-color:#c3c3c3;
border-width:0px 0px 0px 1px;
height:20px;
} </style>
</head>
<body>
<div id="row1" class="myrow">
<table>
<tbody>
<tr>
<td>
<div>
根因1
</div>
</td>
<td>
<div>
</div>
</td>
<td>
<div>
故障场景1
</div>
</td>
<td>
<div>
</div>
</td>
</tr>
</tbody>
</table>
</div> <div id="row2" class="myrow" style="height:30px">
<div class="myfloat">
根因2
</div>
<div class="myfloat myline" >
</div>
<div class="myfloat">
故障场景2
</div>
<div class="myfloat">
</div>
</div> <div id="row3" class="myrow">
<div class="mydisplay">
根因3
</div>
<div class="mydisplay">
</div>
<div class="mydisplay">
故障场景3
</div>
<div class="mydisplay">
</div>
</div> </body>
</html>
<html>
<head>
<style type="text/css">
.myrow{
border:#c3c3c3 1px solid;
height:26px;
margin:5px;
width:90%;
} div div{
float:left;
height:26px;
margin:2px 5px 2px 5px;
} .myline{
border-style:solid;
border-color:#c3c3c3;
border-width:0px 0px 0px 1px;
height:20px;
} .myid{
width:10%;
} .mycause{
width:70%;
} .myimg{
background-image: url(myimg.png);
background-color: #FFFFFF;
width:23px;
height:23px;
margin:3px 0px 3px 5px;
} body{
font-size:15px;
color:#666;
font-family:"Helvetica","微软雅黑";
} </style>
</head>
<body> <div class="myrow">
<div class="myimg">
</div>
<div class="myid" >
根因1
</div>
<div class="myline" >
</div>
<div class="mycause" >
故障场景1
</div>
<input type="checkbox" style="margin:7px">
<div>
</div>
</div> <div class="myrow">
<div class="myimg">
</div>
<div class="myid" >
根因2
</div>
<div class="myline" >
</div>
<div class="mycause" >
故障场景2
</div>
<input type="checkbox" style="margin:7px">
<div>
</div>
</div>
</body>
</html>
CSS布局实战的更多相关文章
- CSS学习笔记--Div+Css布局实战(入门)
基本页面布局 本教程带着大家做一个简单的页面布局 最重效果如下: 1.第一部,先创建上下左右4个DIV <!DOCTYPE html> <html> <head lang ...
- CSS+DIV网页样式布局实战从入门到精通 中文pdf扫描版
CSS+DIV网页样式布局实战从入门到精通通过精选案例引导读者深入学习,系统地介绍了利用CSS和DIV进行网页样式布局的相关知识和操作方法. 全书共21章.第1-5章主要介绍网页样式布局的基础知识,包 ...
- 第6天:DIV+CSS页面布局实战
今天我从早上9:00写代码一直写到下午18:00,写的我差点抑郁了,还好最后终于写出了一个完整页面,没有做动画效果,就是练习了一下DIV+CSS布局,做的是福务达(www.zzfwd.cn)的主页,真 ...
- 3.实战HTML+CSS布局(实例入门篇)
转自:https://www.cnblogs.com/hmyprograming/archive/2012/03/23/2414373.html 学习这篇入门教程我们假定你已经具有了一定的HTML基础 ...
- [转]基于display:table的CSS布局
当IE8发布时,它将支持很多新的CSS display属性值,包括与表格相关的属性值:table.table-row和table-cell,它也是最后一款支持这些属性值的主流浏览器.它标志着复杂CSS ...
- HTML+CSS小实战案例
HTML+CSS小实战案例 登录界面的美化,综合最近所学进行练习 网页设计先布局,搭建好大框架,然后进行填充,完成页面布局 <html> <head> <meta htt ...
- 2天驾驭DIV+CSS (实战篇)(转)
这是去年看到的一片文章,感觉在我的学习中,有不少的影响.于是把它分享给想很快了解css的兄弟们.本文是实战篇. 基础篇[知识一] “DIV+CSS” 的叫法是不准确的[知识二] “DIV+CSS” ...
- 深入css布局篇(1) — 盒模型 & 元素分类
深入css布局(1)-- 盒模型 & 元素分类 " 在css知识体系中,除了css选择器,样式属性等基础知识外,css布局相关的知识才是css比较核心和重要的点.今天我们来深 ...
- 前端开发周报: CSS 布局方式方式与JavaScript数据结构和算法
前端开发周报:CSS 布局方式与JavaScript动画库 1.常见 CSS 布局方式详见: 一些常见的 CSS 布局方式梳理,涉及 Flex 布局.Grid 布局.圣杯布局.双飞翼布局等.http: ...
随机推荐
- 关于byte[]与string、Image转换
byte[]与string转换 参考网址:https://www.cnblogs.com/xskblog/p/6179689.html 1.使用System.Text.Encoding.Default ...
- javascript面向对象中继承实现?
面向对象的基本特征有:封闭.继承.多态. 在javascript中实现继承的方法: 1.原型链(prototype chaining) 2.call()/apply() 3.混合方式(prototyp ...
- Python3学习之路~6.3 类变量 VS 实例变量
类变量 VS 实例变量 #Author:Zheng Na # 实例里面可以查询.增加.删除.修改实例变量 class Role: # 类名 # 类变量 name = '我是类name' n=1 n_l ...
- PE破解win2008登录密码
1.使用PE系统启动计算机. 2.使用cmd命令行程序. 3.备份一下magnify.exe(windows 放大镜程序). copy C:\WINDOWS\system32\magnify.exe ...
- spring框架中的注解
- DL中epoch、batch等的意义【转载】
转自:深度学习中 number of training epochs 中的 epoch到底指什么? - 知乎 https://www.zhihu.com/question/43673341 1. (1 ...
- pycharm tips
批量更改变量名,就在该变量名上shift+f6 ../data 两个点,就是上一级目录,一个点就是当前目录 unhashable type: 'list' 使用set进行去重 a = [1,2,2,3 ...
- SVM、LR、决策树的对比
一.LR LR,DT,SVM都有自身的特性,首先来看一下LR,工业界最受青睐的机器学习算法,训练.预测的高效性能以及算法容易实现使其能轻松适应工业界的需求.LR还有个非常方便实用的额外功能就是它并不会 ...
- Github Issues
快捷键r
- cocos2d JS-(JavaScript) 检测DOM是否可用
function domReady(f) { if (domReady.done) {//如果已经加载完成 马上执行函数 return f(); } if (domReady.timer) {//如果 ...