html/css/js basic.md

2 篇文章 0 订阅

字符编码

所有数据在计算机中存储时都是以二进制进行存储的,文字也不例外。存的时候转换为二进制,读的时候二进制转换为字符

字符集

编码和解码所采用的规则。比如让a对应1,b对应2这种。常见的字符集:ASCII , GB2312,UTF-8(开发时使用的字符集都是UTF-8) 等

< head>头部

帮助浏览器或搜索引擎来解析网页

< meta>

< meta>标签用来设置网页的原数据(底层数据),元数据不是给用户看

  • charset:指定网页的字符集
  • name:指定的数据的名称
  • content:指定的数据的内容
// name中的keywords指的是搜索网站的关键字,也就是可以用content中的abc在浏览器中搜索的关键词
<meta name="keywords" content="abc">

// name中的description指的是这个网站的描述,对应的内容在content中。网站的描述会显示在搜索引擎的搜索结果中
<meta name="description" content="这是一个...的网站">


// 将页面重定向到另一个网站
// content 中的内容指的是3s之后跳转到另一个网站
<meta http-equiv="refresh" content="3; url=https://www.baidu.com/">

// title标签的内容是作为搜索结果的超链接上的文字显示
<title> ddddd </title>
  • 块元素
    在网页中一般通过块元素来进行布局

  • 行内元素

    • 行内元素主要用来包裹文字。一般情况下会在块元素中放行内元素,而不会在行内元素中放块元素
    • 块元素中基本什么都可以放
    • P元素中不能放任何的块元素
  • 浏览器在解析网页时,会自动对网页中不符合规范的内容进行修正:

    • 标签写在了根元素的外部
    • p元素中嵌套了块元素
    • 根元素中出现了除head和body以外的子元素
  • 超链接

    • 将超链接的href属性设置成#之后点击可以回到顶部
    • 可以跳转到页面的指定位置,只需将href的属性值设置成 #目标元素的id属性
<a href="#" Top>
// 跳转到id为bottom的内容处
<a href="#bottom" Top>

内敛框架ifream

用于向当前页面中引入一个其他页面

<iframe width="800" src="https://www.qq.com"></iframe>

选择器

常用选择器

元素选择器
类选择器
id选择器

复合选择器

  • 交集选择器

选中同时符合多个条件的元素,如下面代码中的divred
⚠️ 交集选择器中如果有元素选择器,必须以元素选择器开头(必须是div.red而不是red.div

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  .red{
    color: red;
  }
  div.red{
    font-size: 30px;
  }
  </style>
</head>
<body>
  <div class="red">div</div>
  <p class="red">p</p>
</body>
</html>
  • 并集选择器

同时选择多个选择器对应的元素

h1, div{
color: red;
}

#red, p{
color: red;
}
关系选择器
  • 子元素选择器

选中指定父元素的指定子元素

div > p{
color: red;
}
  • 后代元素选择器

选中指定元素内的指定后代元素

div span{
color: red;
}

相比而言,后代元素选择器的范围比子元素选择器大

  • 兄弟元素选择器
// 选择p标签后面的那个span
div + span{
color: red;
}

// 选择p标签后面的所有span
div ~ span{
color: red;
}
属性选择器
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  div[title]{
    color: red;
  }
  p[title="dddd"]{
    color: aquamarine;
    font-size: 30px;
  }
  h3[title ^= "hhhh"]{
    /* 选择以指定值开头的属性,这里包括hhhh和hhhhii */
    color: coral;
  }
  h5[title $= "jjjj"]{
    /* 选择以指定值结尾的属性,这里包括jjjj和kkjjjj */
    color: crimson;
  }
  h2[title *= "mmmm"]{
    color: teal;
  }
  </style>
</head>
<body>
  <div title="aaaa">div</div>
  <div title="bbbb">div</div>
  <div title="cccc">div</div>
  <p title="dddd">p</p>
  <p title="eeee">p</p>
  <p title="ffff">p</p>
  <h3 title="gggg">span</h3>
  <h3 title="hhhh">span</h3>
  <h3 title="hhhhii">span</h3>
  <h5 title="jjjj">span</h5>
  <h5 title="kkjjjj">span</h5>
  <h5 title="llll">span</h5>
  <h2 title="mmmm">span</h2>
  <h2 title="nmmmmn">span</h2>
  <h2 title="oooo">span</h2>
</body>
</html>

伪类选择器

伪类,就是不存在的类或者特殊的类,用来描述一个元素的特殊状态(如:第一个子元素,被点击的元素,鼠标移入的元素),伪类一般都使用:开头

ul>li:first-child {
  color: aquamarine;
  }
  ul>li:first-child {
    color: aquamarine;
  }

  /* 选中偶数位 */
  ul>li:nth-child(2n){
    color: tomato;
  }
  /* 选中偶数位 */
  ul>li:nth-child(even){
    color: tomato;
  }

  /* 选中奇数位 */
  ul>li:nth-child(2n+1){
    color: tomato;
  }
  /* 选中奇数位 */
  ul>li:nth-child(odd){
    color: tomato;
  }

以上所有的伪类都是根据所有的元素进行排序的

当然还有下面的这些,是在同类型元素中进行排序的

  • first-of-type
  • last-of-type
  • nth-of-type

:not

// 选中ul下面所有的li,除了第三个
ul>li:not(:nth-child(3)) {
 color: red;
}

超链接的伪类

超链接的状态:

  • 访问过的
  • 没访问过的
/* link代表没访问过的链接 */
a:link{
   color: burlywood;
 }
 /* visited代表访问过的链接 ,由于保护隐私的原因,visited这个伪类只能设置链接的颜色,大小等其他的都不能设置*/
 a:visited{
   color: violet;
 }
 /* 鼠标移入的状态 */
 a:hover{
   color: teal;
 }
 /* 鼠标点击的状态 */
 a:active{
   color: steelblue;
 }

伪元素选择器

伪元素表示一些页面中特殊的并不真实的存在的元素(特殊的位置)

使用::开头

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    /* 表示第一个字母 */
    p::first-letter{
      font-size: 30px;
    }
    /* 表示第一行 */
    p::first-line{
      background-color: thistle;
    }
    /* 表示选中的元素 */
    p::selection{
      background-color: teal;
    }

    /* 通过 ::before 和 ::after添加的内容在页面是不能用鼠标来选中的,因为这些是通过css添加的*/
    /* 必须结合content来使用 */
    /* 元素的开始 */
    div::before{
      content: "abc";
      color: aquamarine;
    }
    /* 元素的结束 */
    div::after{
      content: "def";
      color: cadetblue;
    }
  </style>
</head>

<body>
  <div>
      Hooray! It's snowing
  </div>
  <p>
      Hooray! It's snowing! It's time to make a snowman.James runs out. He makes a big pile of snow. He puts a big snowball on top. He adds a scarf and a hat. He adds an orange for the nose. He adds coal for the eyes and buttons.In the evening, James opens the door. What does he see? The snowman is moving! James invites him in. The snowman has never been inside a house. He says hello to the cat. He plays with paper towels.A moment later, the snowman takes James's hand and goes out.They go up, up, up into the air! They are flying! What a wonderful night!The next morning, James jumps out of bed. He runs to the door.He wants to thank the snowman. But he's gone
  </p>
</body>

</html>
### 回答1: 在./src/plugins/index.js中,可以使用require('bootstrap/dist/css/bootstrap.min.css')来引入bootstrap/dist/css/bootstrap.min.css文件。 ### 回答2: 要解决 "bootstrap/dist/css/bootstrap.min.css in ./src/plugins/index.js" 的问题,可以使用以下方法: 1. 确保项目中已经正确安装了 Bootstrap 库。可以运行 npm install bootstrap 命令来安装 Bootstrap,或者在项目的 package.json 文件中添加 Bootstrap 的依赖项。 2. 检查文件路径是否正确。确保文件路径 "./src/plugins/index.js" 是正确的,并且文件确实存在于该路径下。如果文件路径不正确,可以尝试修正路径中的拼写错误或者文件的实际位置。 3. 确保正确引入了 Bootstrap CSS 文件。在 "./src/plugins/index.js" 文件中,检查是否使用了正确的相对路径来引入 Bootstrap 的 CSS 文件。应该使用相对于当前文件的路径来引入 Bootstrap CSS 文件,例如 "../node_modules/bootstrap/dist/css/bootstrap.min.css"。 4. 确保 webpack 配置正确。如果使用 webpack 来构建项目,需要在 webpack 配置文件中添加对 CSS 文件的处理。查找 webpack 配置文件(通常是 webpack.config.js)中的模块配置,确保正确设置了处理 CSS 文件的 loader,例如使用 style-loader 和 css-loader。 5. 如果以上步骤都没有解决问题,可能是由于其他依赖项的冲突或不兼容性造成的。可以通过运行 npm update 命令来更新项目的依赖项,或者检查并解决其他依赖项的版本冲突。 总之,要解决 "bootstrap/dist/css/bootstrap.min.css in ./src/plugins/index.js" 的问题,需要确保正确安装了 Bootstrap,文件路径正确,正确引入 CSS 文件,并且正确配置了 webpack。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值