我的第一个bootstrap页面

本文介绍了一个将普通网页转换成使用Bootstrap框架的实例。通过引入Bootstrap核心CSS和JS文件,实现了响应式布局,并对按钮、警告框等进行了样式调整。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我的第一个bootstrap页面--把现有网页转为bootstrap网页。

原网页:


改后网页:


改后代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head jwcid="@wade:Head" >
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>存量用户导入</title>
<!-- --><link jwcid="@wade:Style" href="component/styles/styles_all.css" rel="stylesheet" type="text/css" media="screen"/>
<link jwcid="@wade:Style" href="component/styles/styles_content.css" rel="stylesheet" type="text/css" media="screen"/>

<!-- Bootstrap core CSS -->
<link href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>

<script jwcid="@wade:Script" type="text/javascript" src="scripts/program/programSale.js"></script>

</head>
<body jwcid="@Body">
  <form jwcid="@Form" enctype="multipart/form-data">
    <div class="popwrapper">

      <div class="alert alert-warning" role="alert" id="tishi" style="display:none">文件正在入库处理中,请耐心等候...,在弹出提示前请不要关闭页面!谢谢.</div>

      <div class="alert alert-info" role="alert">请上传要导入的数据文件</div>

      <div class="panel panel-info">
        <div class="panel-heading">
          <h3 class="panel-title" style="font-size: 14px">插入类型</h3>
        </div>
        <div class="panel-body">
          <select name="queryType" id="queryType">
            <option value="0">实时</option>
            <option value="1">模拟</option>
          </select>
        </div>
      </div>

      <div class="panel panel-info">
        <div class="panel-heading">
          <h3 class="panel-title" style="font-size: 14px">导入TXT文件</h3>
        </div>
        <div class="panel-body">
          <a class="btn-xs" href="attach?file_name=TXT模板及说明.rar&file_path=/salemanm_templet/basicupload/NumberTemplateDescription.rar" target="printframe">导入文件模版</a> <input
            type="file" id="FILE_PATH_TXT" name="FILE_PATH_TXT" desc="导入文件" class="一行数据" /> <br>

            <table border=0>
              <tr>
                <td style="PADDING: 10px;"><input type="submit" class="btn btn-sm btn-info" jwcid="aquery@Submit" value="  导入  " listener="ognl:listeners.dataImportByTxt"
                  onclick="if(getFileSize(document.all('FILE_PATH_TXT').value)){return confirmForm(this)}else{return false;};" /></td>
                <td>
                  <div class="alert alert-danger" style="padding: 5px;margin-bottom: 0px;display: none;" id="file_warning" role="alert">
                    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> 请先选择需要上传的文件
                  </div>
                </td>
              </tr>
            </table>
          </div>
      </div>
      
      <span jwcid="@wade:PageData" />
      </div>
  </form>

  <script>
  	function slideStatus() {
  		if ($("#tishi").is(":hidden")) {
  			$("#tishi").slideDown("slow");
  		} else {
  			$("#tishi").hide();
  		}
  	}
  	
  	function slideWarning()
  	{
  		$("#file_warning").slideDown("slow");
  	}
  
  	function getFileSize(filename) {
  		// var filename = document.all('FILE_PATH').value; //获得上传文件的物理路径
  		if (filename == '') {
  			slideWarning();
  			return false;
  
  		} else {
  			var strRegex = "(.txt)$"; //用于验证扩展名的正则表达式
  			var re = new RegExp(strRegex);
  			if (!re.test(filename.toLowerCase())) {
  				alert("文件名不合法,文件的扩展名必须为.txt格式");
  				slideStatus();
  
  				return false;
  			} else {
  				return true;
  			}
  		}
  	}
  </script>
</body>
</html>

注意事项:

1、下拉框找了很久,没找到;FlatUI里有,但是里面有很多js的实现,迁移过来报错,未解决因此没用;而且是metro风格,用了flatui,就不能用原生的bootstrap,以免风格不统一;

2、fileupload未找到bootstrap的实现,因此暂没改;

3、不太懂怎么改css,所以这么写:<h3 class="panel-title" style="font-size: 14px">导入TXT文件</h3>,我自己感觉比较恶心;

4、不知道bootstrap有否table的实现,所以我这里自己写了table,不好看;

5、这里暂时用到了bootstrap的panel、button、alert;

后续改进点:

1、doctype不要xhtml;改html标签属性;改meta;

2、去掉没用的js引用;

3、学习、优化上述5点还不太懂的内容;

本文出处:http://blog.youkuaiyun.com/ouyida3/article/details/43992795

2015.2.28

### 使用Bootstrap创建第一个项目的指南 #### 创建HTML文件并引入Bootstrap 为了开始使用Bootstrap,首先需要创建一个新的HTML文档。在这个例子中,将展示如何通过CDN方式引入Bootstrap库。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My First Bootstrap Project</title> <!-- 引入最新版本的Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+Knujsl7/1LHxiqhPzgFqWjnzR9nEXJkOcJYh4RDdXw==" crossorigin="anonymous"> </head> <body> <!-- 页面主体内容 --> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js" integrity="sha384-mQ93GR66B00ZXjt0YO5KlohRA5SY2XofN4zfuZxLkoj1gXtW8ANNCe9d5Y3eG5eD" crossorigin="anonymous"></script> </body> </html> ``` 这段代码展示了如何设置基本的HTML模板,并通过CDN链接引入了Bootstrap的核心CSS和JS资源[^2]。 #### 构建简单的页面布局 一旦成功引入了Bootstrap,就可以利用其预定义好的类来设计页面元素。下面是一个非常基础的例子: ```html <div class="container mt-5"> <div class="row justify-content-center"> <div class="col-md-6 text-center"> <h1>Welcome to My Website!</h1> <p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p> <button type="button" class="btn btn-primary">Learn More</button> </div> </div> </div> ``` 这里使用了`container`, `row`, 和 `col-*` 类来自动生成一个居中的两栏式布局,并添加了一个按钮用于增强视觉效果[^1]。 #### 添加更多功能性的组件 随着对Bootstrap熟悉度增加,还可以探索更多的内置组件和服务端插件,比如导航条(navbar),卡片(card), 轮播(carousel)等等。这些都可以大大简化前端开发工作量的同时提升用户体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值