飞行的猪哼哼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

王者荣耀的标题栏:

<!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>
        h3 {
            width: 118px;
            height:40px;
            /* background-color: pink; */
            font-size: 14px;
            font-weight: 400;
            line-height: 40px;
            background-image: url(images/icon.png);
            background-repeat: no-repeat;
            background-position: left center;
            text-indent: 1.8em;
        }
    </style>
</head>
<body>
    <h3>
        成长守护平台
    </h3>
</body>
</html>

在这里插入图片描述
这个小的图片一般不采用在body中插入图片的方式,因为不容易控制位置。而是采用这种背景设置的方式。 line-height: 40px;要和 height:40px;的值相同,这样可以让汉字竖直居中显示。background-repeat: no-repeat;让背景图不平铺,而造成很多图。 background-position: left center;设置背景图左侧居中显示。 text-indent: 1.8em;让文字空格1.8个空格。
超大背景图片

<!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>
        body {
            background-image: url(images/bg.jpg);
            background-repeat: no-repeat;
            background-position: center top;
        }
    </style>
</head>
<body>
    
</body>
</html>
posted on 2020-01-29 10:55  飞行的猪哼哼  阅读(25)  评论(0)    收藏  举报