HTML学习记录 2021.05.13

学习链接:

HTML: HyperText Markup Language

CSS: Cascading Style Sheets

1、CSS文件的添加方式

css文件路径:

css文件路径

css代码:

header{
    text-align: center;
    color: deeppink;
}

#container{
    text-align: center;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

p.tip span {
    font-weight:bold;
    color:#ff9955;
}

.gallery{
    float: left;
    width: 150px;
    padding: 20px;
    margin: 20px;
    border: 1px solid red;
}
.gallery.description{
    padding: 10px;
    text-align: center;

}
.gallery:hover {
    cursor: pointer;
    border-radius: 25px;
    box-shadow: 10px -10px grey;
    border: 1px solid #777;
}


.gallery.img{
    width: 150px;
    height: 150px;
}
a:focus-visible{
    color: aqua;
}
a:visited{
    color: seagreen;
}

a:hover {
    color:red;
}

 

2.CSS部分代码解释

对container的解释

container对应了项目代码中

<div id="container">

这一部分设置的名称

在css文件中通过 #container 的方式设置其属性

#container{
    text-align: center;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

对gallary的解释

gallery对应了项目代码中

<div class="gallery">

这一部分设置的名称

在css文件中设置项目属性时

  1. 可以通过'.'方式检索<div>内部的其他class,例如‘img’  .gallery.img

  2. 可以通过‘:’方式更改某一特定class中的某一属性值,例如‘a’  a:visited

.gallery.img{
    width: 150px;
    height: 150px;
}

a:visited{
    color: seagreen;
}

 

3.HTML部分代码解释

<a>中target标记值的意义:

target中设置的名称对应了不同的弹出页面,如果多个<a>指向了同名target,它们会共用同一个弹出窗口

详见HTML <a> 标签的 target 属性

 

4.HTML代码:

<!--dtd-->
<!DOCTYPE html>
<html>
<head>
    <title>Web Address</title>
    <!--CSS Styles-->
    <link rel="stylesheet" type="text/css" href="css/imgStyle.css">

    <!--HTML -> DOM -> Apply CSS-->
</head>    

<body>
    <header >

        <h1>Web Address</h1>

    </header>

    <div id="container">
        <p class="tip"><span>Tips: </span>This is a test web site</p>
        <div class="gallery">
            <a href="image/imgBaidu.png" target="_baidu">
                <img src="image/imgBaidu.png">
            </a>
            <a href="https://www.baidu.com" target="_baidu">
                <div class="description">Baidu</div>
            </a>
        </div>
        <div class="gallery">
            <a href="image/imgGoogle.png" target="_google">
                <img src="image/imgGoogle.png">
            </a>
            <a href="https://www.google.com" target="_google">
                <div class="description">Google</div>
            </a>
        </div>
    </div>

</body>

</html>

 

5.部分图片

imgBaidu
imgBaidu.png

 

imgGoogle
imgGoogle.png

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值