bootstrap之背景图片+文字2

一 .效果如下

技术要点:

1.背景图片拉伸 background-repeat: no-repeat;   background-size: cover;

2.文字居中 text-align: center;

二 html代码

<!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>Document</title>
    <link rel="stylesheet" href="bootstrap.min.css">
    <script src="bootstrap.min.js"></script>
    <link href="app3.css" rel="stylesheet">
</head>
<body>
    <div class="treepage">
        <div class="treepage-bg" id="treepagebg">
        <div class="treepagecontent">
            <div class="treepagetext">
                <h1>为什么要学习编程</h1>
                <p>daily life</p>
                <p>只要你坚持,就是小菜一碟</p>
            </div>
            <a href="#"  class="btn btn-success btn-lg treepagebtn">快速学习</a>
        </div>
    </div>
</div>
</body>
</html>

三 app3.css

.treepage{
    position: absolute;
    width:100%;
    height:1200px;
}

.treepage-bg{
    position: absolute;
    height:100%;
    width: 100%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}

#treepagebg{
    background-image: url("img/3.png");
}

.treepagecontent{
    width:100%;
    margin:0 auto;
    text-align: center;
}

.treepagetext{
    margin-top:100px;
}

.treepagetext p{
    margin-top:20px;
    color:#000;
    font-size:20px;
    line-height:10px;
}

.treepagebtn{
margin-top:450px;
font-size:25px;
}

 

  • 3
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值