html5源码笔记四【爱创课堂专业前端培训】

一、响应式的实现-媒介查询

@media

实现方式一:把media限定到link中


<aside></aside>

<div class="box1"></div>

<div class="box2"></div>

 

<!--响应式页面兼容移动端代码-->

<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

<link rel="stylesheet" type="text/css" href="css/media1.css" media="screen and (max-width:1000px)"/>

<link rel="stylesheet" type="text/css" href="css/media2.css" media="screen and (min-width:1000px) and (max-width:1500px)"/>

<link rel="stylesheet" type="text/css" href="css/media3.css" media="screen and (min-width:1500px)"/>

 

实现方式二:把media写到css代码中

留活口,ie兼容

@charset "utf-8";

 

*{

margin: 0;

padding: 0;

}

 

aside{

height: 200px;

width: 20%;

float: left;

background: orange;

}

div{

height: 200px;

width: 40%;

float: left;

}

 

div.box1{

background: blue;

}

 

div.box2{

background: pink;

}

 

@media only screen and (min-width: 1000px) and (max-width: 1500px) {

aside{

display: none;

}

 

div.box1{

width: 50%;

background: red;

}

 

div.box2{

width: 50%;

background: purple;

}

}

 

@media only screen and (max-width: 1000px) {

aside{

display: none;

}

 

 

div.box1{

width: 100%;

background: yellow;

}

 

div.box2{

width: 100%;

background: greenyellow;

}

 

1 }

 

 

二、bootstrap介绍

2.1 bootstrap概述

bootstrap 是世界上最受欢迎的前端框架,用于构建响应式、移动设备优先的网站。

bootstrap分为“全局css样式”、“组件”、“javascript插件”这么几个主要的部分。

设置全局 css 样式

基本的 html 元素均可以通过 class 设置样式并得到增强效果;还有先进的栅格系统。

组件

无数可复用的组件,包括字体图标、下拉菜单、导航、警告框、弹出框等更多功能。

javascript插件

jquery 插件为 bootstrap 的组件赋予了“生命”。可以简单地一次性引入所有插件,或者逐个引入到你的 页面中。

2.2 bootstrap引入:

npm 需要安装环境node.js

cdn 在线方式,需要联网

离线的方式  下载引入自己的网站中

<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-gn5384xqq1aowxa+058rxpxpg6fy4iwvtnh0e263xmfcjlsawiggfaw/dais6jxm" crossorigin="anonymous">

1  <!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"--> 

 

2.3 容器及标题标签

类名.container  根据不同视口给出不同的方案,但是都是页面居中的效果

类名 .container-fluid 宽度百分百

标题标签 单位rem 改变了w3c标准样式

<div class="container border2">

  <!-- content here -->

  <h1>这是bootstrap</h1>

  <h2>这是bootstrap</h2>

  <h3>这是bootstrap</h3>

  <h4>这是bootstrap</h4>

  <h5>这是bootstrap</h5>

  <h6>这是bootstrap</h6>

1  </div>

 

2.4 媒体查询:

// small devices (landscape phones, 576px and up)@media (min-width: 576px) { ... }

// medium devices (tablets, 768px and up)@media (min-width: 768px) { ... }

// large devices (desktops, 992px and up)@media (min-width: 992px) { ... }

// extra large devices (large desktops, 1200px and up)@media (min-width: 1200px) { ... }

或:

// extra small devices (portrait phones, less than 576px)@media (max-width: 575.98px) { ... }

// small devices (landscape phones, 576px and up)@media (min-width: 576px) and (max-width: 767.98px) { ... }

// medium devices (tablets, 768px and up)@media (min-width: 768px) and (max-width: 991.98px) { ... }

// large devices (desktops, 992px and up)@media (min-width: 992px) and (max-width: 1199.98px) { ... }

// extra large devices (large desktops, 1200px and up)@media (min-width: 1200px) { ... }

 

 

2.5 网格布局

栅格系统用于通过一系列的行(row)与列(column)的组合来创建页面布局,你的内容就可以放入这些创建好的布局中

类名row 行  必须包含在 .container (固定宽度)或 .container-fluid (100% 宽度)中,以便为其赋予合适的排列(aligment)和内补(padding)。

类名 col- 列、栏   通过“行(row)”在水平方向创建一组“列(column)” ,内容应当放置于“列(column)”内,并且,只有“列(column)”可以作为行(row)”的直接子元素

一行一共有12栏,如果一行多余12栏,会自动换行

响应式:

.col-

.col-sm-

.col-md-

.col-lg-

.col-xl-

 

偏移值:

offset-  

<div class="container">

  <div class="row">

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

  </div>

  <div class="row">

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

  </div>

  <div class="row">

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

  </div>

  <div class="row">

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

    <div class="col-sm">

      one of three columns

    </div>

  </div>

</div>

 

<div class="container-fluid">

   <div class="row">

   <div class="col-2">

   col-2

   </div>

   <div class="col-8">

   col-8

   </div>

   <div class="col-2">

   col-2

   </div>

  </div>

  <div class="row">

   <div class="col-3">

   col-3

   </div>

   <div class="col-6">

   col-6

   </div>

   <div class="col-3">

   col-3

   </div>

  </div>

1  </div>

 

2.6 文本与排版

使用 Bootstrap 的排版特性,可以创建标题、段落、列表及其他内联元素,实际上它是把大部分在HTML的基本标签加了样式。

<div class="container">

<p class="text-left text-success bg-info">这是关于排版和文本效果的应用</p>

<p class="text-center text-info bg-warning">这是关于排版和文本效果的应用</p>

<p class="text-right text-warning bg-success">这是关于排版和文本效果的应用</p>

<p class="text-hide"</p>

<p class="text-danger bg-primary">这是关于排版和文本效果的应用</p>

<p class="text-muted bg-danger">这是关于排版和文本效果的应用</p>

1  </div>

 

2.7 表格

1 默认样式

2 .table

3 可选样式

4 .table-striped  为表格提供了斑马线的样式

5 .table-bordered  为表格增加边框(border)

6 .table-hover 为表格中的每一行赋予鼠标悬停样式。鼠标划过后会添加一个背景色。

7 .table-condensed 每个单元格的内补(padding)减半,可使表格更紧凑。

 

<div class="container">

<table class="table table-striped table-bordered table-hover table-warning table-sm">

  <thead>

    <tr class="bg-danger">

      <th scope="col">#</th>

      <th scope="col">First</th>

      <th scope="col">Last</th>

      <th scope="col">Handle</th>

    </tr>

  </thead>

  <tbody>

    <tr>

      <th scope="row">1</th>

      <td>Mark</td>

      <td>Otto</td>

      <td>@mdo</td>

    </tr>

    <tr>

      <th scope="row">2</th>

      <td>Jacob</td>

      <td>Thornton</td>

      <td>@fat</td>

    </tr>

    <tr>

      <th scope="row">3</th>

      <td>Larry</td>

      <td>the Bird</td>

      <td>@twitter</td>

    </tr>

  </tbody>

</table>

1  </div>

 

2.7 表单

 

2.8 按钮

 

<div class="container-fluid">

<button type="button" class="btn btn-primary">Primary</button>

<button type="button" class="btn btn-secondary">Secondary</button>

<button type="button" class="btn btn-success">Success</button>

<button type="button" class="btn btn-danger">Danger</button>

<button type="button" class="btn btn-warning">Warning</button>

<button type="button" class="btn btn-info">Info</button>

<button type="button" class="btn btn-light">Light</button>

<button type="button" class="btn btn-dark">Dark</button>

 

<button type="button" class="btn btn-link">Link</button>

</div>

 

<div class="container">

<button type="button" class="btn btn-primary">按钮</button>

<button type="button" class="btn btn-primary">按钮</button>

<button type="button" class="btn btn-primary">按钮</button>

<button type="button" class="btn btn-primary">按钮</button>

</div>

 

<div class="container">

<button type="button" class="btn btn-light">按钮</button>

<button type="button" class="btn btn-light">按钮</button>

<button type="button" class="btn btn-light">按钮</button>

<button type="button" class="btn btn-light">按钮</button>

1  </div>

 

2.9 卡片 面包屑

 

<div class="container">

<div class="row">

<div class="col-4">

<div class="card" style="width: 18rem;">

  <img class="card-img-top" src="images/1.jpg" alt="Card image cap">

  <div class="card-body">

    <h5 class="card-title">Card title</h5>

    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>

    <a href="#" class="btn btn-primary">Go somewhere</a>

  </div>

</div>

</div>

<div class="col-4">

<div class="card" style="width: 18rem;">

  <img class="card-img-top" src="images/1.jpg" alt="Card image cap">

  <div class="card-body">

    <h5 class="card-title">Card title</h5>

    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>

    <a href="#" class="btn btn-primary">Go somewhere</a>

  </div>

</div>

</div>

<div class="col-4">

<div class="card" style="width: 18rem;">

  <img class="card-img-top" src="images/1.jpg" alt="Card image cap">

  <div class="card-body">

    <h5 class="card-title">Card title</h5>

    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>

    <a href="#" class="btn btn-primary">Go somewhere</a>

  </div>

</div>

</div>

</div>

1  </div>

 

2.9 轮播图

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<link rel="stylesheet" type="text/css" href="bootstrap-4.0.0-dist/css/bootstrap.css"/>

<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

</head>

<body>

<div class="container">

<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">

  <ol class="carousel-indicators">

    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>

    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>

    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>

  </ol>

  <div class="carousel-inner">

    <div class="carousel-item active">

      <img class="d-block w-100" src="images/1.jpg" alt="First slide">

    </div>

    <div class="carousel-item">

      <img class="d-block w-100" src="images/2.jpg" alt="Second slide">

    </div>

    <div class="carousel-item">

      <img class="d-block w-100" src="images/3.jpg" alt="Third slide">

    </div>

  </div>

  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">

    <span class="carousel-control-prev-icon" aria-hidden="true"></span>

    <span class="sr-only">Previous</span>

  </a>

  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">

    <span class="carousel-control-next-icon" aria-hidden="true"></span>

    <span class="sr-only">Next</span>

  </a>

</div>

</div>

</body>

</html>

原文地址:https://www.cnblogs.com/Vhaomei0452/p/11395853.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


前端工程师一般用的是Bootstrap的框架而不是样式,样式一般自己重新定义class类即可,主要样式要随具体情况而定包括位置任何带有class.btn的元素都会继承圆角灰色按钮的默认外观。但是Bootstrap提供了一些选项来定义按钮的样式。<buttontype="button"class="btn">基本
起步导入:<linkrel="stylesheet"href="bootstrap-3.3.7-dist/css/bootstrap.css"><scriptsrc="js/jquery-3.3.1.js"></script><scriptsrc="bootstrap-3.3.7-dist/js/bootstrap.js"></script>屏幕
(1)modal声明一个模态框(2)modal-dialog定义模态框尺寸(3)modal-lg定义大尺寸模态框(4)modal-sm定义小尺寸模态框(5)modal-header(6)modal-body(7)modal-footer<!doctypehtml><html><head><metacharset="utf-8"><title>模态框<itle><linkrel=&quo
图片在Bootstrap版本3中,通过为图片添加 .img-responsive 类可以让图片支持响应式布局。其实质是为图片设置了 max-width:100%;、 height:auto; 和 display:block; 属性,从而让图片在其父元素中更好的缩放。如果需要让使用了 .img-responsive 类的图片水平居
<inputtype="text"class="form-controldatepicker"style="padding:0.375rem0.75rem;"placeholder="开始时间"readonly="true" id="start_time"name="start_time"> $(".datepicke
目录bootstrap-treeview使用小记零、写在前面的话一、功能说明二、特性简述三、实战3.1依赖环境3.2数据源格式3.3Options选项3.4Methods方法3.5Events事件N-2、番外N-1、本文demoN、参考资料bootstrap-treeview使用小记零、写在前面的话p.s.bootst
  一、应用http://www.bootcss.com/进入bootstrap4或bootstrap3中文网,想要快速地将Bootstrap应用到你的项目中,有以下两种办法: 1、bootstrap可以在线引用,方法如下:A、CSS将引入Bootstrap样式表的 <link> 标签复制并粘贴到 <head> 中,并放在所有其他样式表之前。<!
第87节:Java中的Bootstrap基础与SQL入门前言复习什么是JQ?:writelessdomore写更少的代码,做更多的事找出所有兄弟:$("div").siblings()基本过滤器:选择器:过滤器$("div:first"):first:找到第一个元素:last:找到最后一个元素:even:找出偶数索引:odd:找出奇叔索引
1.bootstrap表单(1)form声明一个表单域(2)form-inline内联表单域(3)form-horizontal水平排列表单域(4)form-group表单组、包括表单文字和表单控件(5)form-control文本输入框、下拉列表控件样式(6)checkboxcheck-inline多选框样式(7)radioradio-inline单选框样式(8)input-group表单控件组
<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>首页<itle><
嗯。。。以前做ssh。应该是stratusspringhibernate。 然后现在来了一个新的需求。 要用java,bootstrap,oracle,springboot,jquery,mybatis。 开始,我也挺心虚的,但是后来一看,,,其实本没有必要这么虚。。。毕竟。。。这些东西,写的有问题。。。问题在于没有逻辑。 bootstrap,j
表格基本实例为任意 <table> 标签添加 .table 类可以为其赋予基本的样式—少量的内补(padding)和水平方向的分隔线。这种方式看起来很多余!?但是我们觉得,表格元素使用的很广泛,如果我们为其赋予默认样式可能会影响例如日历和日期选择之类的插件,所以我们选择将此样式独立出来。
1、问题背景   一般情况下,查询列表有查询条件、查询按钮和重置按钮,输入查询条件,点击查询按钮查询列表等数据;点击重置按钮会将查询条件恢复到原始状态 2、实现源码 <!DOCTYPEhtml><html> <head> <metacharset="UTF-8"> <title>Bootstrap-查询按钮和重置按钮<
Bootstrap简介什么是Bootstrap?Bootstrap官网框架:库liblibraryjQuery作为一个框架来讲,提供一套比较便捷的操作DOM的方式把大家都需要的功能预先写好到一些文件这就是一个框架Bootstrap让我们的Web开发更简单,更快捷;注意是Bootstrap不是BootStrap!这是一个词,不是
1.bootstrap图片img-responsive声明响应式图片2.bootstrap字体图标通过字体代替图标,font文件夹需要和css文件夹在同一目录3.bootst导航条(1)navbar声明导航条(2)navbar-default声明默认的导航条样式(3)navbar-inverse声明反白的导航条样式(4)navbar-static-top去掉导航条的圆角(5)n
1.路径导航<!doctypehtml><html><head><metacharset="utf-8"><title>路径导航<itle><linkrel="stylesheet"type="text/css"href="css/bootstrap.min.css"><scripttype="text/ja
问题描述:最近在学习BootStrap,过程中遇到引用glyphicon图标无法显示的问题,经过在百度后该问题已解决。1、首先看一下图标显示失败的页面:2、经过参考大佬们的经验,我找到了解决办法。首先我的BootStrap的css样式表是经过下载之后直接拷贝了其中一个文件到编译器中使用的,没有把所有
BootStrap布局一、BootStrap布局CSS组件主要包括栅格系统、列表组、进度条、icon图标、导航栏等组件。JavaScript插件主要有动画效果、窗体模式、下拉菜单、选项卡等二、网格系统Bootstrap内置了一套响应式、移动优先的流式栅格系统,随着屏幕设备或可视窗口(viewport)尺寸的
1引入所需要的文件2用法
想让bootstrap的table列内容超出部分省略号,要在table上加table-layout:fixed和word-break:break-all,然后在头部thead的th加上宽度百分比,最后在列里加个标签如span,在这个span加上单行超出部分省略号的css:display:inline-block,overflow:hidden,white-space:nowrap,text-overflow:e