Bulma教程

Bulma 文件

说明

它用于通过使用 input 标签中的 .file 元素从用户数据上传文件。 .file 元素是一个主容器,包括以下子元素-
.file-label-它被视为元素的可点击部分。 .file-input-出于某些样式目的而隐藏。 .file-cta-它调用上传过程。 .file-icon-指定上传图标。 .file-label-定义文件标签的文本。 .file-name-返回所选文件的名称。
让我们使用上面的子元素创建一个简单的文件上传示例,如下所示-
<!DOCTYPE html>
<html>
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <title>Bulma Forms Example</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
      <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
   </head>
   
   <body>
      <section class = "section">
         <div class = "container">
            <span class = "title">
               File Upload
            </span>
            <br>
            <br>
            
            <div class = "file">
               <label class = "file-label">
                  <input class = "file-input" type = "file" name = "fileupload">
                  <span class = "file-cta">
                     <span class = "file-icon">
                        <i class = "fas fa-upload"></i>
                     </span>
                     <span class = "file-label">
                        Upload a file…
                     </span>
                  </span>
               </label>
            </div>
            
         </div>
      </section>
      
   </body>
</html>
它显示以下输出-

颜色和尺寸

Bulma 提供了以下 10 个修饰符来设置文件元素的样式。
is-white is-black is-light is-dark is-primary is-link is-info is-success is-warning is-danger
您还可以通过使用 3 个额外的尺寸来使用文件元素-
is-small is-medium is-large
下面的例子描述了上述修饰符的用法和文件元素的大小-
<!DOCTYPE html>
<html>
   <head>
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <title>Bulma Forms Example</title>
      <link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
      <script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
   </head>
   
   <body>
      <section class = "section">
         <div class = "container">
            <span class = "is-size-5">
               File Upload Color Modifiers
            </span>
            <br>
            <br>
            
            <div class = "field">
               <div class = "file is-primary">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Primary File Upload…
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file is-info has-name">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Info File Upload…
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file is-warning">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-cloud-upload-alt"></i>
                        </span>
                        <span class = "file-label">
                           Warning File Upload…
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file is-danger has-name is-boxed">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-cloud-upload-alt"></i>
                        </span>
                        <span class = "file-label">
                           Danger File Upload…
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            <br>
            <br>
            
            <span class = "is-size-5">
               File Upload Sizes
            </span>
            <br>
            <br>
            
            <div class = "field">
               <div class = "file is-small">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Small File Upload...
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Normal File Upload...
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file is-medium">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Medium File Upload...
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
            <div class = "field">
               <div class = "file is-large">
                  <label class = "file-label">
                     <input class = "file-input" type = "file" name = "fileupload">
                     <span class = "file-cta">
                        <span class = "file-icon">
                           <i class = "fas fa-upload"></i>
                        </span>
                        <span class = "file-label">
                           Large File Upload...
                        </span>
                     </span>
                  </label>
               </div>
            </div>
            
         </div>
      </section>
      
   </body>
</html>
执行上述操作,您将获得以下输出-
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4