CSS实例:图片导航块

  1. 认识CSS的 盒子模型。
  2. CSS选择器的灵活使用。
  3. 实例:
    1. 图片文字用div等元素布局形成HTML文件。
    2. 新建相应CSS文件,并link到html文件中。
    3. CSS文件中定义样式
      1. div.img:border,margin,width,float
      2. div.img img:width,height
      3. div.desc:text-align,padding
      4. div.img:hover:border
      5. div.clearfloat:clear

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PHOTO</title>
    <link rel="stylesheet" type="text/css" href="../static/css/1020.css">
</head>
<body>
<div class="logo">
    <div class="small">
        <a href="https://bangumi.bilibili.com/anime/2580?from=search&seid=18070620123919499344">
            <img src="https://i0.hdslb.com/bfs/bangumi/207b3c90f16629eb54f060d54d5efb7d29bb9563.jpg_225x300.jpg"></a>
        <div class="describe"><a href="https://bangumi.bilibili.com/anime/2580?from=search&seid=18070620123919499344">干物妹小埋</a></div>
    </div>
    <div class="small">
        <a href="https://bangumi.bilibili.com/anime/1660">
            <img src="https://i0.hdslb.com/bfs/bangumi/d3ce7564ddf58b2f7245b104fb578a5655e55168.jpg_225x300.jpg"></a>
        <div class="describe"><a href="https://bangumi.bilibili.com/anime/1660">夏目友人帐</a></div>
    </div>
    <div class="small">
        <a href="https://bangumi.bilibili.com/anime/1586">
            <img src="https://i0.hdslb.com/bfs/bangumi/e1f891ad2602265655f3ef181e343e253f017fce.jpg_225x300.jpg"></a>
        <div class="describe"><a href="https://bangumi.bilibili.com/anime/1586">Fate/stay night</a></div>
    </div>
    <div class="small">
        <a href="https://bangumi.bilibili.com/anime/3450">
            <img src="https://i0.hdslb.com/bfs/bangumi/14ba6643f22405e2777cca992002cc6411601334.jpg_225x300.jpg"></a>
        <div class="describe"><a href="https://bangumi.bilibili.com/anime/3450">在下坂本</a></div>
</div>
    <div class="clean">
        <img src="https://i0.hdslb.com/bfs/bangumi/207b3c90f16629eb54f060d54d5efb7d29bb9563.jpg_225x300.jpg">
        <img src="https://i0.hdslb.com/bfs/bangumi/d3ce7564ddf58b2f7245b104fb578a5655e55168.jpg_225x300.jpg">
        <img src="https://i0.hdslb.com/bfs/bangumi/e1f891ad2602265655f3ef181e343e253f017fce.jpg_225x300.jpg">
        <img src="https://i0.hdslb.com/bfs/bangumi/14ba6643f22405e2777cca992002cc6411601334.jpg_225x300.jpg">
</div>

</body>
</html>

CSS

div.small{
    width:200px;
    float:left;
    margin:20px;}
div.small img{
    width:100%;
    height:auto;
    }
div.describe{
    text-align:center;
    padding:2px;}
div.small:hover{
    border:1px solid #777777;}
div.clean{
    clear: both;
}

运行结果

转载于:https://www.cnblogs.com/Qzlhxxx/p/7699203.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值