HTML5+CSS3 学习笔记 14

视频资源:https://www.bilibili.com/video/BV14J4114768?from=search&seid=3842566320098741425

视频记录 267-273

margin负值运用

浏览器渲染顺序:

1.渲染第一个li,边框是1px;

2.渲染第二个li,边框是1px,与第一个li重叠是2px,接着执行-1px,得到结果是1px。

行内块元素应用

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>行内块的巧妙运用</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .box {
            text-align: center; /*重点 父级元素居中,子元素全体居中*/
        }
        .box a {
            display: inline-block;
            width: 36px;
            height: 36px;
            background-color: #f7f7f7;
            border: 1px solid #ccc;
            text-align: center;
            line-height: 36px;
            text-decoration: none;
            color: #333;
            font-size: 14px;
        }
       .box .prev,
        .box .next {
            width: 85px;
        }
        .box .current,
        .box .elp { /*增加权重*/
            background-color: #fff;
            border: none;
        }
        .box input {
            height: 36px;
            width: 45px;
            border: 1px solid #ccc;
            outline: none;
        }
        .box button {
           width: 60px;
           height: 36px;
           background-color: #f7f7f7;
            border: 1px solid #ccc;
            
        }
    </style>
</head>
<body>
    <div class="box">
        <a href="#" class="prev">&lt;&lt;上一页</a>
        <a href="#" class="current">2</a>
        <a href="#">3</a>
        <a href="#">4</a>
        <a href="#">5</a>
        <a href="#">6</a>
        <a href="#" class="elp">...</a>
        <a href="#" class="next">&gt;&gt;下一页</a>
        到第
        <input type="text">
        页
        <button>确定</button>
    </div>
</body>
</html>

CSS 三角强化

三角强化小练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>CSS三角强化的巧妙运用</title>
    <style>
        .price {
            width: 160px;
            height: 24px;
            line-height: 24px; /*父亲垂直居中,特价-原价也会垂直居中*/
            border: 1px solid red;
            margin: 0 auto;
        }
        .miaosha {
            position: relative; /*绝对定位,子绝父相*/
            float: left; /*一个浮动,一行内全部元素都浮动(原价也浮动)*/
            width: 90px;
            height: 100%;
            background-color:red;
            text-align: center; /*水平居中*/
            color: #fff; /*字体为白色*/
            font-weight: 700; /*加粗*/
            margin-right: 8px;
        }
        .miaosha i {
            position: absolute; /*绝对定位,子绝父相*/
            right: 0; /*三角定位至右侧上角*/
            top: 0; /*三角定位至右侧上角*/
            width: 0; /*绝对定位,宽度为0*/
            height: 0; /*绝对定位,高度为0*/
            border-color: transparent #fff transparent transparent; /*只要右边三角符号*/
            border-style: solid;
            border-width: 24px 10px 0 0;  /*三角符号上面较宽*/
        }
        .origin {
            font-size: 12px;
            color: gray;
            text-decoration: line-through; /*文字删除线*/
        }
    </style>
</head>
<body>
    <div class="price">
        <span class="miaosha">
            ¥1650
            <i></i><!--i标签用来做三角-->
        </span>
        <span class="origin">¥5650</span>
    </div>
</body>
</html>
CSS初始化:重设浏览器的样式。(CSS reset)
  • 所有网页必须首先进行CSS初始化,保证浏览器的兼容性。
/* 把我们所有标签的内外边距清零 */
* {
    margin: 0;
    padding: 0
}
/* em 和 i 斜体的文字不倾斜 */
em,
i {
    font-style: normal
}
/* 去掉li 的小圆点 */
li {
    list-style: none
}
img {
    /* border 0 照顾低版本浏览器 如果 图片外面包含了链接会有边框的问题 */
    /* IE6 图片默认有边框 */
    border: 0;
    /* 取消图片底侧有空白缝隙的问题 */
    vertical-align: middle;
}
button {
    /* 当我们鼠标经过button 按钮的时候,鼠标变成小手 */
    cursor: pointer
}
a {
    color: #666; /*链接颜色*/
    text-decoration: none; /*链接无下划线*/
}
a:hover {
    color: #c81623
}
button,
input {
    /* "\5B8B\4F53" 就是宋体的意思 这样浏览器兼容性比较好 */
    font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif
}
body {
    /* CSS3 抗锯齿形 让文字显示的更加清晰 */
    -webkit-font-smoothing: antialiased;
    
    background-color: #fff;
    font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
    color: #666
}

.hide,
.none {
    display: none
}
/* 清除浮动 */
.clearfix:after {
    visibility: hidden;
    clear: both;
    display: block;
    content: ".";
    height: 0
}
.clearfix {
    *zoom: 1
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值