HTML:图像

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图像</title>
</head>
<body>
    <!-- 原图像显示 -->
    <img src="http://www.imooc.com/static/img/index/logo.png" />
    <!-- 设置宽、高 -->
    <img width="100px" height="20px" src="http://www.imooc.com/static/img/index/logo.png" />
    <!-- 在图像无法显示时,会显示alt的内容,告诉用户此处放了一个怎样的图像 -->
    <!-- 此处src故意写错,便于查看效果 -->
    <img alt="imooc-logo" src="http://www.imooc.com/static/img/index/logo.pn" />
</body>
</html>

输出:
在这里插入图片描述

通过非标签的方式插入图像

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图像</title>
    <style>
        /* . 是为了匹配文档中指定类名的 */
        /* 非标签方式插入图像 */
        .imooc-logo {
            background: url("http://www.imooc.com/static/img/index/logo.png");
            width: 100px;
            height: 80px;
        }
    </style>

</head>
<body>
    <img alt="imooc-logo" src="http://www.imooc.com/static/img/index/logo.png" />
    <p class="imooc-logo"></p>

</body>
</html>

在这里插入图片描述

插入本地图像

使用绝对路径:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图像</title>
    <style>
        /* . 是为了匹配文档中指定类名的 */
        /* 非标签方式插入图像 */
        .imooc-logo {
            /* 绝对路径 */
            background: url("E:/java_code/java_stream/animal.jpg");
            width: 300px;
            height: 200px;
        }
    </style>
 
</head>
<body>
    <img alt="imooc-logo" src="http://www.imooc.com/static/img/index/logo.png" />
    <p class="imooc-logo"></p>

</body>
</html>

在这里插入图片描述
相对路径:

/* 相对路径 */
background: url("../java_stream/animal.jpg");

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值