第05章節-Python3.5-元件BootStrap、EasyUI、JQueryUI24

阿啦卜發表於2018-07-20

BootStrap

2、元件

BootStrap
    - css
    - js

學習 BootStrap 規則

  • 一、響應式

      @media
    
  • 在以下目錄新建s3.html:

  • 目的/我想設定一種效果,當螢幕小於或大於多少時,讓某個值生效/

    image.png
  • s3.html 程式碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--stytle-->
    <style>
        .c1{
            background-color: red;
            height:50px;
        }
        /*我想設定一種效果,當螢幕小於或大於多少時,讓某各值生效*/
        @media (min-width: 900px){
            .c2{
            background-color: grey;
            }
        }


    </style>
</head>
<body>
    <!--.c1-->
    <div class="c1 c2"></div>

</body>
</html>
    • 然後在瀏覽器開啟s3.html 效果圖如下:

      image.png
    • 螢幕縮小效果:

      image.png
  • 二、圖示、字型

      @font-face
    

<span class=”glyphicon-class”>glyphicon glyphicon-cloud</span>

  • 三、基本使用(BootStrap使用方法)

    • 把BootStrap原始碼放到以下目錄:

      image.png

所有到檔案目錄如下:

image.png

image.png

把這塊原始碼複製

image.png
    • 新建s4.html檔案(s4.html), s4.html程式碼如下(加入按鈕式下拉選單):
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--link-->
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap-theme.css">
</head>
<body>

    <!--這塊是自己想要那個按鈕或那個表格就直接複製原始碼就可以了-->
    <div class="btn-group">
      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Action <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Separated link</a></li>
      </ul>
    </div>



    <!--先匯入jQuery-->
    <script src="jquery-1.12.4.js"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</body>
</html>
    • 效果圖:

      image.png
  • 步驟同上:

    image.png
  • 修改s4.html程式碼如下(加入導航條):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--link-->
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap-theme.css">
</head>
<body>

    <!--加入導航條-->
    <nav class="navbar navbar-default">
  <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="#">Brand</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="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

    <!--自己想要那個按鈕或那個表格就直接複製原始碼就可以了-->
    <div class="btn-group">
      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Action <span class="caret"></span>
      </button>
      <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Separated link</a></li>
      </ul>
    </div>



    <!--先匯入jQuery-->
    <script src="jquery-1.12.4.js"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</body>
</html>
  • 效果圖:

    image.png
image.png
  • 接著這一步重要(因為導航條的樣式4周的框有點圓角,我想把它改成邊角)
    • 接下來改屬性這樣改(修改屬性有優先順序說法)
      • 修改如下s4.html這塊的程式碼(一般不這樣寫):
</head>
<body style="background-color: red">

    <!--加入導航條-->
    <nav class="navbar navbar-default" role="navigation" style="border-radius: 0">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
image.png
  • 開啟瀏覽器效果圖:

    image.png
  • 正確寫在css中如下修改s4.html這塊程式碼如下:

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--link-->
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap-theme.css">
    <style>
        .no-radus{
            border-radius: 0
        }
    </style>
</head>
<body style="background-color: red">

    <!--加入導航條-->
    <nav class="navbar navbar-default no-radus" role="navigation">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">

也獲得同樣效果:

image.png

另一種寫法s4.html:

<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        .no-radus{
            border-radius: 0 !important;
        }
    </style>
    <!--link-->
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap-theme.css">

</head>
<body style="background-color: red">

    <!--加入導航條-->
    <nav class="navbar navbar-default no-radus" role="navigation">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">


相關文章