前端全栈资料-css2

发布时间 2023-05-30 21:21:37作者: 彭邦森

入门

1-特殊选择器多类名

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .aqua{
            color: aqua;
        }
        .font{
            font-size: 10px;
        }
    </style>
</head>
<body>
<div class="aqua font">刘德华</div>
</body>
</html>
 
2-字体样式
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        h2 {
            font-family: 华文隶书;
        }

        p {
            font-family: 楷书;
            font-size: 16px;
        }
        div{
            /*粗*/
            /*font-weight: bold;*/
            /*font-weight: 700;*/
            /*细*/
            /*font-weight: normal;*/
            font-weight: 200;
        }
        span{
            /*斜体*/
            font-style: italic;
        }
        em{
            font-style: normal;
        }
    </style>
</head>
<body>
<h2>pink的秘密</h2>
<p>那一抹众人中最漂亮的颜色,</p>
<p>优雅,淡然,又那么心中清澈.</p>
<p>前端总是伴随着困难和犯错,</p>
<p>静心,坦然,攻克一个又一个.</p>
<div>这是pink的秘密也是老师最终的嘱托.</div>
<br/>
<span>拼死也要克服它,</span>
<em>变回来</em>
</body>
</html>
 
3-字体复合属性写法
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    /*大小和什么样的字体*/
    div {
        /*italic 倾斜*/
        /*font-style: italic; 字体样式*/
        /*font-weight: 700; 字体粗细*/
        /*font-size: 16px; 字体大小*/
        /*line-height: 28px;*/
        /*font-family: 华文隶书; 什么样的字体*/
        font: italic 700 16px/28px '华文隶书';
    }
</style>
<body>
<div>这是我的秘密也是老师最终的嘱托.</div>
<div>这是我的秘密也是老师最终的嘱托.</div>
<div>这是我的秘密也是老师最终的嘱托.</div>
</body>
</html>
 
4-文本装饰
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div {
            /*下划线*/
            /*text-decoration: underline;*/
            /*删除线*/
            /*text-decoration: line-through;*/
            /*上划线*/
            text-decoration: overline;
            /*行高*/
            line-height: 90px;
        }

        a {
            text-decoration: none;
        }

        /*文本缩进*/
        p{
            /*像素*/
            /*text-indent: 20px;*/
            /*文字距离*/
            text-indent: 2em;
        }
    </style>
</head>
<body>
<div>
    弃如敝屣弃如敝屣弃如敝屣
</div>
<a href="#">sasasas</a>
<p>弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣</p>
<span>弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣弃如敝屣</span>
</body>
</html>
 
5-复合选择器之链接伪类选择器
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*点击*/
        a:link {
            color: red;
            text-decoration: none;
        }

        /*点击过*/
        a:visited {
            color: aqua;
        }

        /*经过*/
        a:hover {
            color: pink;
        }

        /*选择的是我们鼠标正在按下还没有弹起鼠标的那个链接*/
        a:active {
            /*color: yellow;*/
        }
    </style>
</head>
<body>
<div>
    <a href="#">复合选择器之链接伪类选择器</a>
    <a href="#">复合选择器之链接伪类选择器</a>
</div>
</body>
</html>
 
6-focus伪类选择器
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*把获得光标的input表单元素选取出来*/
        input:focus {
            background-color: red;
        }
    </style>
</head>
<body>
<input type="text">
<input type="text">
<input type="text">
</body>
</html>