CSS样式

首字母样式

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    p {
        font-size: 14px;
        line-height: 1.5em;
    }
    
    p::first-line {
        background: rgba(0, 0, 0, .1);
    }
    
    /* 为类选择器选中 第一个字符; */
    p::first-letter {
        color: #B76E2D;
        float: left;
        font-size: 60px;
        font-weight: bold;
        line-height: 1;
        margin-right: 12px;
        text-shadow: 3px 5px 0 #232839;
        transform: rotate(-2deg);
    }
    </style>
</head>

<body>
    <p>HTML-Hyper Text Markup Language超文本标记语言,利用标记来呈现网页内容。W3c组织负责制定网页相关标准,目前HTML的最新版本为html5,新增了很多语义化标签(header、aritcle、nav、main、section、footer等)、嵌入媒体(audio、vedio、canvas、svg等)、web API(离线存储、地理位置等),为网页的快速发展增添助力。</p>
</body>

</html>

文字基线

<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="utf-8" />
    <title>vertical-align</title>
    <style>
        .test p{border:1px solid #000;font-size:16px;line-height:2;}
        .test a{margin-left:5px;font-size:12px;}
        .baseline a{vertical-align:baseline;}
        .sub a{vertical-align:sub;}
        .super a{vertical-align:super;}
        .top a{vertical-align:top;}
        .text-top a{vertical-align:text-top;}
        .middle a{vertical-align:middle;}
        .bottom a{vertical-align:bottom;}
        .text-bottom a{vertical-align:text-bottom;}
        .length a{vertical-align:10px;}
    </style>
</head>
<body>
<ul class="test">
    <li class="baseline">
        <strong>与基线对齐</strong>
        <p>参考内容<a href="?">基线对齐</a></p>
    </li>
    <li class="sub">
        <strong>与参考内容的下标对齐</strong>
        <p>参考内容<a href="?">下标对齐</a></p>
    </li>
    <li class="super">
        <strong>与参考内容的上标对齐</strong>
        <p>参考内容<a href="?">上标对齐</a></p>
    </li>
    <li class="top">
        <strong>对象的内容与对象顶端对齐</strong>
        <p>参考内容<a href="?">要对齐的内容</a></p>
    </li>
    <li class="text-top">
        <strong>对象的文本与对象顶端对齐</strong>
        <p>参考内容<a href="?">要对齐的内容</a></p>
    </li>
    <li class="middle">
        <strong>对象的内容与对象中部对齐</strong>
        <p>参考内容<a href="?">要对齐的内容</a></p>
    </li>
    <li class="bottom">
        <strong>对象的内容与对象底端对齐</strong>
        <p>参考内容<a href="?">要对齐的内容</a></p>
    </li>
    <li class="text-bottom">
        <strong>对象的文本与对象顶端对齐</strong>
        <p>参考内容<a href="?">要对齐的内容</a></p>
    </li>
    <li class="length">
        <strong>与基线算起的偏移量</strong>
        <p>参考内容<a href="?">偏移量对齐</a></p>
    </li>
</ul>
</body>
</html>

hover样式提示

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>CSS实现的工具提示</title>
    <style>
    body {
        text-align: center;
        background: #C2E2F2;
        font-size: 18px;
        color: #444;
    }
    
    a {
        color: #1A5A7A;
        text-decoration: none;
    }

    /**
	 * HINT- A CSS tooltip library
	 */
    
    .hint {
        position: relative;
        display: inline-block;
    }
    
    .hint:before,
    .hint:after {
        position: absolute;
        opacity: 0;
        z-index: 1000000;
        transition:all 0.3s ease;
        pointer-events: none;
    }
    
    .hint:hover:before,
    .hint:hover:after {
        opacity: 1;
    }
    
    .hint:before {
        content: '';
        background: transparent;
        border: 6px solid transparent;
    }
    
    .hint:after {
        content: attr(data-hint);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
        box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    }

    /* top */
    .hint-top:before {
        bottom: 100%;
        left: 50%;
        margin: 0 0 -18px 0;
        border-top-color: rgba(0, 0, 0, 0.8);
    }
    .hint-top:after {
        bottom: 100%;
        left: 50%;
        margin: 0 0 -6px -10px;
    }
    .hint-top:hover:before {
        margin-bottom: -10px;
    }
    .hint-top:hover:after {
        margin-bottom: 2px;
    }

    /* default: bottom */
    .hint-bottom:before {
        top: 100%;
        left: 50%;
        margin: -14px 0 0 0;
        border-bottom-color: rgba(0, 0, 0, 0.8);
    }
    .hint-bottom:after {
        top: 100%;
        left: 50%;
        margin: -2px 0 0 -10px;
    }
    .hint-bottom:hover:before {
        margin-top: -6px;
    }
    .hint-bottom:hover:after {
        margin-top: 6px;
    }

    /* right */
    .hint-right:before {
        left: 100%;
        bottom: 50%;
        margin: 0 0 -4px -8px;
        border-right-color: rgba(0, 0, 0, 0.8);
    }
    .hint-right:after {
        left: 100%;
        bottom: 50%;
        margin: 0 0 -13px 4px;
    }
    .hint-right:hover:before {
        margin: 0 0 -4px -0;
    }
    .hint-right:hover:after {
        margin: 0 0 -13px 12px;
    }

    /* left */
    .hint-left:before {
        right: 100%;
        bottom: 50%;
        margin: 0 -8px -4px 0;
        border-left-color: rgba(0, 0, 0, 0.8);
    }
    .hint-left:after {
        right: 100%;
        bottom: 50%;
        margin: 0 4px -13px 0;
    }
    .hint-left:hover:before {
        margin: 0 0 -4px 0;
    }
    .hint-left:hover:after {
  	   margin: 0 12px -13px 0;
    }
    </style>
</head>

<body>
    <h2>工具提示</h2>
    <p>利用::before、::after伪对象实现的工具提示</p>
    <article>
        <a href="#" class="hint  hint-top" data-hint="工具提示"></a>
        <a href="#" class="hint  hint-right" data-hint="工具提示"></a>
        <a href="#" class="hint  hint-bottom" data-hint="工具提示"></a>
        <a href="#" class="hint  hint-left" data-hint="工具提示"></a>
    </article>
</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值