<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>div</title>
<style>
.c1 {
border-left: 10px solid aqua;
border-right: 10px solid aquamarine;
border-bottom: 10px solid #0000FF;
border-top: 10px solid #FF0000;
/* 居中 */
margin: 0 auto;
width: 100px;
height: 100px;
}
.c2 {
border: 10px solid blue;
margin: 15px;
}
* {
margin: 0;
padding: 0;
}
.box1 {
width: 200px;
height: 200px;
background: yellowgreen;
margin: 30px;
}
.box2 {
width: 200px;
height: 200px;
background: gray;
margin: 20px;
}
</style>
</head>
<body>
<div class="c1"></div><!-- div特征 块级元素独占一行 默认:w宽度为浏览器宽,h高度0,高度会被内容撑开 -->
<div class="c2"></div>
<!-- margin的塌陷 两个盒子的margin的相交时,会出现margin值小的失效 -->
<!-- 垂直之间塌陷的原则是以两盒子最大的外边距为准。 -->
<div class="box1">box1</div>
<div class="box2">box2</div>
</body>
</html>
<!DOCTYPE html>
<html><!---->
<head>
<meta charset="utf-8" />
<title>case1</title>
<style>
body{margin: 0;}
img{}
.c1{
width: 100px;
height: 100px;
border: 5px solid red;
border-bottom: 5px blue;
border-top: 5px slide yellow;
border-right: 5px slide trasparent;/* 透明 */
/* 没有给到的值参考对立面,顺时针顺序,上右下左 */
padding: 10px;
/* 居中方式一 上下为零,左右居中 */
margin: 0 auto;
/* 块级元素 */
/* display: block; */
/* 默认垂直对齐基线 去掉图片底部的3像素 */s
vertical-align: bottom;
}
div{
/* 居中方式二 */
width: 100px;
margin:0 auto;
}
</style>
</head>
<body>
<div> <!-- 盒子 -->
<img style="width: 100px; height: 300px;" src="js/case%2001.jpg" alt=""> <!-- w100 tab 快捷键 -->
</div>
<span id="">
Aj
</span>
<img class="c1" src="js/case2.jpg" alt=""><!-- 基线 -->
<span>字段1</span> <!-- 块级元素独占一行 -->
<span>字段二</span>
</body>
</html>
<!DOCTYPE html>1
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.box1{
border: 1px solid red;
width: 300px;
/* height: 300px; */
}
.box2{
border: 1px solid black;
/* width: 100px; */
height: 150px;
float: left;/* 浮动子盒的宽度是内容宽 内容不够,在加宽度 */
}
.box3{
border: 1px solid blue;
width: 100px;
height: 150px;
float: left;
}
.box4{border: 1px solid green;}
</style>
</head>
<body>
<div class="box1">
<div class="box2">1111111</div>
<div class="box3"></div>
</div>
<div class="box4">
浮动子盒的宽度是内容宽 浮动的子盒撑不开父子盒,浮动盒子盖住其他盒,子盒宽度小于父盒
div特征 块级元素独占一行 默认:w宽度为浏览器宽,h高度0,高度会被内容撑开
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.box1{
border: 10px solid red;
width: 300px;
height: 300px;
padding: 20px;
}
.box2{
border: 10px solid blue;
background-color: yellow;
/* width: 290px; */
height: 290px;
}
.box3{
margin: 30px;
border: 10px solid green;
height: 280px;
/* width: 280px; */
}
嵌套 margin塌陷
父盒子与子盒子一起与页面顶端产生了10px间隙
为父盒子设置border,为外层添加border后父子盒子就不是真正意义上的贴合。
</style>
</head>
<body>
<!-- div.box1>div.box2>div.box3 -->
<div class="box1">
<div class="box2">
<div class="box3">123</div>
</div>
</div>
</body>
</html>
1 div和浮动 浮动子盒的宽度是内容宽 浮动的子盒撑不开父子盒,浮动盒子盖住其他盒,子盒宽度小于父盒 div特征 块级元素独占一行 默认:w宽度为浏览器宽,h高度0,高度会被内容撑开 有关快级元素: none 此元素不会被显示。 block 此元素将显示为块级元素,此元素前后会带有换行符。 inline 默认。此元素会被显示为内联元素,元素前后没有换行符。 inline-block 行内块元素。(CSS2.1 新增的值) 2 /* 闭合浮动/请浮动 */ 文字 /*
第一种方法:在浮动子盒的下面加一个div 加上clear:both
在parent容器中,在子元素的最后
加入一个空的块级元素,并给它一个拥有clear:both属性的clear的类选择器。
第二种,在parent容器中添加overflow:auto的属性,并针对于IE6增加zoom:1的属性
第三种,在parent容器添加一个:
after伪元素,
并使用content:"."或者为" "
在元素的后面生成了内容为一个点的块级元素,
并使用一切方法使这个块级元素隐藏并清除浮动clear:both。
/* 在父盒 使用after:{clear:both} */
.clearfix::before,
.clearfix::after {
content: ">>>>";
display: table;
}
.clearfix::after {
clear: both;
}
“第四种,让parent容器也浮动。”
只需给parent容器添加 float:left,也可闭合浮动。
文字
font-size: 15px;
/* 斜体 默认normal */
font-style:italic;
/*字体 */
font-family:"Times New Roman";
color:red;
/* 修饰 */
text-decoration:none;
/* 上划线 */
/* text-decoration:overline; */
/* 删除线 */
/* text-decoration:line-through; */
/* 下划线 */
/* text-decoration:underline; */
width: 200px;
height: 200px;
border: 1px solid #7FFFD4;
/* 行高 */
line-height: 20px;
color: #55ff7f;
animation-direction: normal;
unicode-bidi: bidi-override;
/* letter-spacing:6px ; */
word-spacing: 7px;
white-space: 6px;
/* 对齐方式 */
/* text-align:center; */
/* text-align:right; */
/* text-align:left; */
/* 两端对齐 */
text-align:justify;
/* 对齐 */
text-align-last:center;
<!-- 注意:text-align-last 属性只有在 text-align 属性设置为 "justify" 时才起作用。 -->
/* 装饰 下划线 */
text-decoration: underline;
text-indent: 20px;
text-transform: uppercase;
text-transform: capitalize;
</body>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>wedding</title>
<style>
body {
margin: 0;
}
div {
/* margin: auto; */
}
/* *{}通配符选择器 */
* {
margin:0;
}
img {
display: block;
/* margin: auto; */
vertical-align: bottom;
}
.w {
margin: 0 auto;
width: 1080px;
}
/*提供寬度才能居中*/
/* 提出公共代碼 */
.head {
/* border: 12px solid red; */
/* 观察div */
}
.ad {
/* margin: 0 auto;
width: 1080px; */
padding: 15px 0 15px 0;
}
.ap {
/* margin: 0 auto;
width: 1080px; */
}
.bd {
/* 边框测试用例 */
border: 1px solid #FF0000;
}
.banerL {
float: left;
}
.banerR {
float: right;
}
.baner {
float: left;
padding-top: 15px;
}
.baner img {
padding-right: 15px;
}
.baner img:nth-child(3) {
padding-right: 0;
}
.fl {
float: left;
}
.fr {
float: right;
}
/* 以下为main区 */
.main {}
.brand {
padding-top: 15px;
height: 460px;
}
.brand .fl {
/* width: 259px; */
padding-right: 15px;
}
.brand .fl:nth-child(4) {
padding-right: 0;
}
.title {
border-bottom: 2px solid #f6f5f3;
padding-top: 35px;
/* height: 42px; */
}
.title .h3 {
font-family: "黑体";
font-style: 24px;
height: 42px;
}
.sty{
padding-top: 15px;
padding-right: 15px;
height: 600px;/* 设置高度撑开 */
}
.s {
}
.s img {
padding-bottom: 15px;
/* height: 460px; */
}
.s .fl {
padding-right: 15px;
}
.s .fl:nth-child(3) {
padding-right: 0;
}
/* user */
.user {
padding-top: 15px;
padding-bottom: 15px;
height: 164px;
}
.user .fl:nth-child(3) {
padding-right: 0;
}
.user .fl:nth-child(2) {
padding-right: 44px;
}
.user .fl {
padding-right: 15px;
}
/* hun */
.hun{}
.hun_L {
padding-right: 15px;
}
.hun_L div {
padding-top: 15px;
}
.hun_R .fl {
padding-right: 15px;
padding-top: 15px;
}
.hun_R .fl:nth-child(3) {
padding-right: 0;
}
.hun_R .fl:nth-child(6) {
padding-right: 0;
}
/* 粉色 */
.pink{
height: 220px;
width: 355px;
background-color: #ff6783;
margin-bottom: 15px;
padding-left: 20px;
}
.pinkTop{
width: 334px;
height: 84px;
border-bottom: 2px solid #ff798a ; /* */
}
.pinkTop h4{
font-weight: 400;
color: #ffffff;
padding-top: 19px;
padding-bottom: 1px;
font-size: 23px;
}
.pinkTop p{
font-size: 13px;
color: #ffffff;
}
.pinkButton{
height: 135px;
padding-top: 7px;
}
.bai{
height: 16px;
background-color: #ffffff;
float: left;
color: #f62b48;
font-family: "黑体";
font-size: 13px;
border-radius: 3px;
margin-right: 15px;
margin-top: 15px;
padding:2px 4px 1px 4px;
}
.bai:nth-child(7){
margin-right: 86px;
}
</style>
</head>
<body>
<!-- head區 -->
<!-- div*3>img -->
<!-- div.fl*3>img -->
<div class="w head"><img src="img/case-01_03.gif" alt=""></div>
<div class="w ad"><img src="img/case-01_06.gif" alt=""></div>
<div class="w ap"><img src="img/case-01_08.gif" alt=""></div>
<!-- baner区 -->
<!-- div.baner -->
<div class=" w">
<div class="banerL">
<div><img src="img/banner_L.gif" alt=""></div>
<div class="baner">
<div class="fl"> <img src="img/baner1.gif" alt=""></div>
<div class="fl"> <img src="img/baner2.gif" alt=""></div>
<div class="fl"> <img src="img/baner3.gif" alt=""></div>
</div>
</div>
<div class="banerR"><img src="img/baner-R.gif" alt=""></div>
</div>
<!-- main区 -->
<div class="w main">
<div class="title">
<h3>品牌</h3>
</div>
<div class="brand">
<!-- div.fl*3>img -->
<div class="fl"><img src="img/main.jpg" alt=""></div>
<div class="fl"><img src="img/main2.jpg" alt=""></div>
<div class="fl"><img src="img/maincase-02_03_03.jpg" alt=""></div>
<div class="fl"><img src="img/maincase-02_03_07.jpg" alt=""></div>
</div>
<div class="title">
<h3>风格</h3>
</div>
</div>
<!-- style区 -->
<div class="w sty">
<div class="fl s">
<div class="pink">
<div class="pinkTop">
<h4>太原婚纱照精选商家</h4>
<p>Featured businesses</p>
</div>
<div class="pinkButton">
<div class="bai"><p>太原金夫人</p></div>
<div class="bai"><p>幸福V摄影</p></div>
<div class="bai"><p>罗亚摄影</p></div>
<div class="bai"><p>爱萌18号</p></div>
<div class="bai"><p>栖溪创意水下摄影</p></div>
<div class="bai"><p>布拉格</p></div>
<div class="bai"><p>凯瑟琳摄影</p></div>
<div class="bai"><p>佳丽新娘婚纱</p></div>
<div class="bai"><p>爱上婚纱摄影</p></div>
<div class="bai"><p>卡罗摄影</p></div>
</div>
</div>
<div><img src="img/style-01_29.gif" alt=""></div>
</div>
<div class="fr s">
<div class="fl">
<div class=""><img src="img/style-01_17.gif" alt=""></div>
<div class=""><img src="img/style-01_25.gif" alt=""></div>
<div class=""><img src="img/style-01_33.gif" alt=""></div>
</div>
<div class="fl">
<img src="img/style-01_19.gif" alt="">
<img src="img/style-01_26.gif" alt="">
<img src="img/style-01_34.gif" alt="">
</div>
<div class="fl">
<img src="img/style-01_21.gif" alt="">
<img src="img/style-01_27.gif" alt="">
<img src="img/style-01_35.gif" alt="">
</div>
</div>
</div>
<!-- user -->
<!-- <div class="bd w"><img src="img/user.gif" alt=""></div> -->
<div class="w user">
<div class="title">
<h3>用户 </h3>
</div>
<div class="fl"><img src="img/use1.gif" alt=""></div>
<div class="fl"><img src="img/user2.gif" alt=""></div>
<div class="fl"><img src="img/user3.gif" alt=""></div>
<div class="fr"><img src="img/user4.gif" alt=""></div>
</div>
<!-- hun -->
<div class="w hun">
<div class="title">
<h3>婚庆</h3>
</div>
<div class="hun_L fl">
<div class=""><img src="img/hun_L1.gif" alt=""></div>
<div class=""><img src="img/hun_L2.gif" alt=""></div>
</div>
<div class="hun_R">
<div class="fl"><img src="img/hun_R1.gif" alt=""></div>
<div class="fl"><img src="img/hun_R2.gif" alt=""></div>
<div class="fl"><img src="img/hun_R3.gif" alt=""></div>
<div class="fl"><img src="img/hun_R4.gif" alt=""></div>
<div class="fl"><img src="img/hun_R5.gif" alt=""></div>
<div class="fl"><img src="img/hun_R6.gif" alt=""></div>
</div>
</div>
<div class="foot w"><img src="img/foot.gif" alt=""></div>
</body>
</html>