前端学习开发实例 静态网页(Bootstrap)

参考视频:【极客学院】一周学会Bootstrap

官方文档: Bootstrap 中文文档 · Bootstrap 是世界上最流行的、移动设备优先的、响应式前端开发框架。


文章目录

  • 功能需求
  • 结果展示
  • 源代码
    • 文件目录
    • index_test1.html
    • index_test1_css.css



功能需求

实现一个静态界面。
包含背景图片。(使用background-image样式属性)
包含头部导航栏,含搜索功能等。(使用bootstrap导航栏)
包含底部脚注,含文本。(使用bootstrap导航栏)
包含巨幕,包含文本和按钮。(使用bootstrap巨幕)


结果展示




源代码


文件目录

  • 根目录
  1. index_test1.html 网页源代码
  2. index_test1_css.css 样式源代码
  • 文件夹
  1. image/
    s2.jpg 背景图片
  2. css/
    bootstrap.css bootstrap样式


index_test1.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>一个基于BS的尝试</title>
<!--  <script src="js/jquery-3.5.1.js"></script>
  <script src="js/bootstrap.js"></script>-->
  <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  <link rel="stylesheet" type="text/css" href="index_test1_css.css">

</head>
<body>

  <div class="mybackground"> <!--背景:使用固定图片-->
    
    
    <header class="myheader"> <!--头部-->
      <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">This is my web</a>
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
              <li class="active"><a href="#">One <span class="sr-only">(current)</span></a></li>
              <li><a href="#">Two</a></li>
              <li><a href="#">Three</a></li>
            </ul>
            <form class="navbar-form navbar-left">
              <div class="form-group">
                <input type="text" class="form-control" placeholder="What you want">
              </div>
              <button type="submit" class="btn btn-info">Search</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
              <li><a href="#">Contact us</a></li>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">User <span class="caret"></span></a>
                <ul class="dropdown-menu">
                  <li><a href="#">Login</a></li>
                  <li><a href="#">Post</a></li>
                  <li role="separator" class="divider"></li>
                  <li><a href="#">Any information</a></li>
                </ul>
              </li>
            </ul>
          </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
      </nav>
    </header>


    <section class="mysection"> <!--主体部分-->
      <aside class="myaside">
        <p> </p>
      </aside> <!--左附加信息-->
      <article class="myarticle">
        <h1>My web has its title</h1>
        <br>
        <p>
          I am happy to join with you today in what will go down in history as the greatest demonstration for freedom in the history of our nation.
          Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of bad captivity.
        </p>
        <br>
        <p class="mybutton">
          <button type="button" class="btn btn-success btn-lg">Join us</button>
          &emsp14;&emsp14;&emsp14;&emsp14;
          &emsp14;&emsp14;&emsp14;&emsp14;
          <button type="button" class="btn btn-info btn-lg">Learn more</button>
        </p>

      </article><!--右主要内容-->
    </section>


    <footer> <!--尾部-->
      <nav class="navbar navbar-inverse navbar-fixed-bottom myfooternav" >
        <div class="container">
          <p class="navbar-text">This is my first web basing on bootstrap, html, css. I'll add some javascript if I can. @zhm</p>
        </div>
      </nav>
    </footer>
    
    
  </div>

</body>
</html>


index_test1_css.css

.mybackground{
  width: 100%;
  height: 600px;
  background-image: url("image/s2.jpg");
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-position: center;
  float: left;
}

.myheader{
  width: 100%;
  height: 10%;
  float: left;
}

.mysection{
  width: 100%;
  height: 80%;
  float: left;
}

.myaside{
  width: 45%;
  float: left;
}

.myarticle{
  width: 55%;
  float: left;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.myarticle h1 , .myarticle h2, .myarticle p{
  color: #ffffff;
}

.myarticle h1{
  font-size: 70px;
}

.mybutton{
  text-align: center;
}

.myfooternav{
  width: 100%;
  height: 10%;
  background-color: transparent; /*背景色:transparent为透明*/
  /*opacity*//*透明属性:0-1.00的小数*/
  margin: 0px;
  float: left;
}

你可能感兴趣的:(前端学习开发实例)