web前端知识——iframe标签、CSS

一、iframe标签

用于在一个网页里面打开另一个网页

 <iframe src="https://www.taobao.com" frameborder="0" width="500" height="600"></iframe>
  • src :指定显示的网页地址
  • width 宽度
  • height 高度
  • scrolling 是否显示滚动条 yes\no
  • frameborder 是否显示边框 1\0

显示某宝网站
在这里插入图片描述

和a标签一起运用,在页面窗口内打开其他网页

 <a href="https://www.taobao.com" target="chuangk">打开淘宝</a>
         <iframe  frameborder="0" width="500" height="600" scrolling="yes" name="chuangk"></iframe>

在这里插入图片描述

二、CSS概念、写法、引入方式

1、概念

CSS(Cascading Style Sheets)层叠样式表 决定网页的样式
学习CSS最重要的事情是学习和掌握CSS样式属性名和对应的属性值,并且灵活运用

2、基本写法和语法

选择器、样式属性名、样式属性值

选择器{
    样式属性名:样式属性值;
    样式属性名:样式属性值;
}

选择器:用来匹配对应的标签,目的就是让CSS可以知道去修饰哪些内容

3、引入方式

第一种:写在html里面的style标签之间,style一般放在head标签里面

<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>
               h1{
                    color:blue
               }
               h3{
                    color:red
               }
          </style>
     </head>
     <body>
        <h1>你好</h1>
        <h2>我不好</h2>
        <h3>你为什么不好呢?</h3>
        <h1>没有为什么</h1>
     </body>
</html>

在这里插入图片描述
第二种:写在外部的CSS文件里面,然后通过link标签引入这个样式文件

    <link rel="stylesheet" href="style.css">
    <h4>好吧</h4>

在这里插入图片描述
在这里插入图片描述

第三种:写在标签的style属性里面
<标签名 style=“样式属性名:样式属性值 样式属性名2:样式属性值2”;>内容</标签名>

<h5 style="color:red">不好吧</h5>

在这里插入图片描述

4、常用选择器

  1. 标签选择器 标签名
  2. 通配选择器 * 所有标签元素
  *{
       background-color:black;
   }
  1. class选择器 .class值
  .ok{
       color:blue
   }
  <h5 class="ok">不好吧</h5>
  1. ID选择器
  #ok{
       color:blue
   }
  <h5 id="ok">不好吧</h5>
  1. 后代选择器
    选择器1 选择器2 { 样式描述 }
<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>
                    h1{
                         color:red
                    }
                    h1{
                         color:blue
                    }
                   
                    div h1{
                         color:black
                    }
          </style>
     </head>
     <body>
        <h1>你好</h1>
        <div>
             <h3>你好</h3>
        </div>
     </body>
</html

在这里插入图片描述

如果某个样式已经被前面选择题定义了,后面再次被定义会发生什么?
例子

<!deoctype.html>
<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>
                    h1{
                         color:red
                    }
                    h1{
                         color:blue
                    }
          </style>
     </head>
     <body>
        <h1>你好</h1>
     </body>
</html>

在这里插入图片描述

子代选择器 选择器1>选择器2

<!deoctype.html>
<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>                
                    div h1{
                         color:darkred
                    }
                    .box>h1{
                         color:yellow
                    }
          </style>
     </head>
     <body>
        <h1>你好</h1>
        <div class="box">
          <h1>你好</h1>
          <div class="dd">
               <h3>我好</h3>
          </div>   
          <h1>你好</h1>
        </div>
     </body>
</html>

同级的选择器会被后面的覆盖
不同级的选择器优先级如何?

  • 通配选择器 权重:0
  • 标签选择器 权重:1
  • class选择器 权重:10
  • id选择器 权重:100
  • 内联样式(上述第三种引入方式) 权重:1000
  • !important 权重:无穷大
 h1{
       color: pink !important;
 }

三、常用样式属性

border 边框

值:  宽度xpx  类型solid/dotted/dashed  颜色 颜色的单词 / #+色号 / RGB(a,b,c)
多边定义:border : width; type color
单边定义:border-left / right / top / bottom : width type color

  • 块元素:默认的宽度是它所在父元素的宽度,默认独占一行
  <style>
               .box{
                    border: 8px dotted red;
                    width: 200px;
                    height: 100px;
               } 
               
  </style>
     </head>
     <body>
          <div class="box">
               <h2>大家好</h2>
          </div>
     </body>

在这里插入图片描述

  • 行内元素: 行内元素,宽高无效

  • 行内块元素:会和行内元素,行内块元素在一行,并且宽高是有效的

   <style>
               input{
                    width:100px;
                    height: 100px;
                    border:2px solid red
               }
               
          </style>
     </head>
     <body>
          <input type="text">
     </body>

在这里插入图片描述

字体

font-size 字体大小 一般pc端,最小字体是12px

     <style>
               h1{
                    font-size: 20px;
               }
          </style>
     </head>
     <body>
          <h1>呵呵</h1>
     </body>

font-family 字体类型

     <style>
               h1{
                    font-size: 20px;
               		font-family:"宋体";
               }
          </style>
     </head>
     <body>
          <h1>呵呵</h1>
     </body>

font-weight 控制字体加粗 normal(不加粗) \ bold(加粗)\ 数字
font-style 控制字体倾斜 italic(倾斜) \ normal(不倾斜)

文本

text-align 设置文本水平对齐方式 center \ left \ right \ justify(两端对齐)
text-decoration 设置删除线 line-through \ none
text-transform 大小写转化 uppercase(大写) \ lowercase(小写) \ capitalize(将第一个字母变成大写)
letter-spacing 字间距 : 数字px;
line-height 行高 : 数字px;
white-space 控制换行 nowrap \ normal(不换行)
overflow : hidden; 超出的部分隐藏
text-overflow : ellipsis 显示省略号

列表

list-style:none 去除列表前面的点
list-style-type 规定点的类型
list-style-image 规定点的类型变成图片
list-style-position 规定点的位置是里面还是外面 inside \ outside

背景

background-color 设置背景颜色
background-image : url(地址) 设置背景为图片
background-repeat : no-repeat(没有平铺) repeat-x(横向平铺) repeat-y(纵向平铺)
background-size: 数字 \ 百分号 \ cover \ contain
background-position 背景图靠近边框的位置

表格

border-collapse 表格风格效果 collapse(合并) separate(展开)
vertical-align: 单元格内容垂直方向 top bottom middle

轮廓、显示、隐藏

outline 边框周边加入其他元素 width \ style \ color
box-shadow 边框阴影 (横向偏移 纵向偏移 阴影模糊距离 阴影的大小 颜色 内部 \ 外部)
display none(消失) \ inline(行内元素) \ inline-block \ block(块元素)
visibility hidden(也是消失,但是位置还会保留) visible(显示)
opacity 透明度 0-1
a 的链接样式

  • link 鼠标没有点击的时候
  • hover 鼠标移动到上面的时候 所有的标签都有hover
  • active 鼠标点击的时候
  • visited 鼠标点击,浏览过后

四、浮动

如何将块元素放在同一行,且宽高有效
1、变成行内块元素 line-block (很大的兼容性问题)

<!deoctype.html>
<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>
               .box{
                    width:800px;
                    height:600px;
                    background-color: #ddd;
                    font-size: 0px;
               } 
               .a{
                    width: 200px;
                    height: 600px;
                    background-color: blue;
                    display: inline-block;
               }
               .b{
                    width: 400px;
                    height: 600px;
                    background-color: green;
                    display: inline-block;
               }
               .c
               {
                    width: 200px;
                    height: 600px;
                    background-color: black;
                    display: inline-block;
               }
          </style>
     </head>
     <body>
     <div class="box">
          <div class="a"></div>
          <div class="b"></div>
          <div class="c"></div>

     </div>
     </body>
</html>

在这里插入图片描述
2、浮动原理
float:left \ right \ none

<!deoctype.html>
<html>
     <head>
          <meta  charset="utf-8" >  
          <title>Hello World</title>
          <style>
                .content{
                    width: 150px;
                    height: 150px;
                    line-height: 50px;
                    font-size: 40px;
                    text-align: center;
                    float: left;
               }           
               .a{
                    background-color: blue;
                   
               }
               .b{
                    background-color: green;
                   
               }
               .c{
                    background-color: pink; 
               }
          </style>
     </head>
     <body>
     <div >
          <div class="a content">1</div>
          <div class="b content">2</div>
          <div class="c content">3</div>

     </div>
     </body>
</html>

在这里插入图片描述
浮动的元素,其实在网页里面没有位置
解决这个问题:
第一种办法: 给父元素加上一个属性:overflow:hidden
第二种办法:浮动的父元素后面加上一个空的标签,这个空标签有一个属性:clear:both

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
iframe标签有几个属性可以使用。其中一些属性包括: 1. src:指定要在iframe中加载的文档的URL。 2. width和height:指定iframe的宽度和高度。 3. frameborder:指定是否显示iframe周围的边框。 4. scrolling:指定是否显示滚动条。 5. name:为iframe指定一个名称,以便在JavaScript中引用它。 6. sandbox:指定iframe中加载的文档的安全策略。 7. allowfullscreen:允许在iframe中全屏播放视频。 8. onload:指定当iframe加载完成时要执行的JavaScript代码。 以上是一些常用的iframe标签属性,您可以根据具体需求选择适合的属性来定制您的iframe元素。 [2 [3<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [iframe标签用法详解(属性、透明、自适应高度)](https://download.csdn.net/download/weixin_38744803/14830588)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [iframe标签(属性介绍(sandbox、srcdoc、scrolling)、iframe对象、onload事件、父集获取iframe内节点...](https://blog.csdn.net/AIWWY/article/details/121153507)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值